build(fmt): replace fmt with std format (#191)

This commit is contained in:
Xenxo Espasandín 2024-02-11 18:12:26 +01:00 committed by GitHub
parent b8d2c84ae0
commit fdd052dad9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
35 changed files with 804 additions and 843 deletions

View File

@ -69,7 +69,7 @@ jobs:
build-macos:
name: Build macOS
runs-on: macos-latest
runs-on: macos-13
strategy:
fail-fast: false
matrix:
@ -86,6 +86,16 @@ jobs:
fetch-depth: 0
lfs: false
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Install LLVM
run: brew install llvm
- name: Add LLVM to PATH
run: |
echo "/usr/local/opt/llvm/bin" >> $GITHUB_PATH
- name: Add premake5 to PATH
uses: abel0b/setup-premake@v2.3
with:
@ -119,7 +129,7 @@ jobs:
- release
arch:
- x64
- arm64
# - arm64
steps:
- name: Check out files
uses: actions/checkout@v4
@ -128,11 +138,15 @@ jobs:
fetch-depth: 0
lfs: false
- name: Install dependencies (arm64)
if: matrix.arch == 'arm64'
- name: Install LLVM
run: |
sudo apt-get update
sudo apt-get install crossbuild-essential-arm64 -y
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17
# - name: Install dependencies (arm64)
# if: matrix.arch == 'arm64'
# run: sudo apt-get install crossbuild-essential-arm64 -y
- name: Add premake5 to PATH
uses: abel0b/setup-premake@v2.3
@ -150,8 +164,8 @@ jobs:
pushd build
make config=${{matrix.config}}_${{matrix.arch}} -j$(nproc)
env:
CC: clang
CXX: clang++
CC: clang-17
CXX: clang++-17
- name: Upload ${{matrix.arch}} ${{matrix.config}} binaries
uses: actions/upload-artifact@v3.1.3

3
.gitmodules vendored
View File

@ -2,9 +2,6 @@
path = deps/zlib
url = https://github.com/madler/zlib
branch = master
[submodule "deps/fmt"]
path = deps/fmt
url = https://github.com/fmtlib/fmt
[submodule "deps/cxxopts"]
path = deps/cxxopts
url = https://github.com/jarro2783/cxxopts.git

1
deps/fmt vendored

@ -1 +0,0 @@
Subproject commit 67c0c0c09cf74d407d71a29c194761981614df3e

31
deps/fmt.lua vendored
View File

@ -1,31 +0,0 @@
fmt = { base = path.join(dependencies.base, "fmt") }
function fmt:include()
includedirs { path.join(fmt.base, "include") }
end
function fmt:link()
links { "fmt" }
self:include()
end
function fmt:project()
project "fmt"
kind "StaticLib"
language "C++"
self:include()
files
{
path.join(fmt.base, "include/fmt/*.h"),
path.join(fmt.base, "src/*.cc")
}
removefiles
{
path.join(fmt.base, "src/fmt.cc")
}
end
table.insert(dependencies, fmt)

26
deps/zlib.lua vendored
View File

@ -15,24 +15,24 @@ function zlib:project()
language "C"
warnings "off"
if os.istarget("linux") or os.istarget("macosx") then
defines {
"HAVE_UNISTD_H"
}
elseif os.istarget("windows") then
defines {
"_CRT_SECURE_NO_WARNINGS",
"_CRT_NONSTDC_NO_DEPRECATE",
"_CRT_SECURE_NO_DEPRECATE",
}
end
self:include()
files
{
files {
path.join(zlib.base, "*.h"),
path.join(zlib.base, "*.c")
}
defines
{
"_CRT_SECURE_NO_WARNINGS",
"_CRT_NONSTDC_NO_DEPRECATE",
"_CRT_SECURE_NO_DEPRECATE",
}
if os.istarget("darwin") then
defines "HAVE_UNISTD_H"
end
end
table.insert(dependencies, zlib)

View File

@ -517,13 +517,13 @@ stmt_for
stmt_foreach
: FOREACH LPAREN expr_identifier IN expr RPAREN stmt
{
auto array = expr_identifier::make(@$, fmt::format("_a{}", ++index));
auto key = expr_identifier::make(@$, fmt::format("_k{}", ++index));
auto array = expr_identifier::make(@$, std::format("_a{}", ++index));
auto key = expr_identifier::make(@$, std::format("_k{}", ++index));
$$ = stmt_foreach::make(@$, std::move($5), std::move($3), std::move(array), std::move(key), std::move($7), false);
}
| FOREACH LPAREN expr_identifier COMMA expr_identifier IN expr RPAREN stmt
{
auto array = expr_identifier::make(@$, fmt::format("_a{}", ++index));
auto array = expr_identifier::make(@$, std::format("_a{}", ++index));
$$ = stmt_foreach::make(@$, std::move($7), std::move($5), std::move(array), std::move($3), std::move($9), true);
}
;
@ -1161,7 +1161,7 @@ auto map_token(context const* ctx_, token& tok) -> parser::symbol_type
}
}
throw error(fmt::format("unmapped token! {}", (u8)tok.type));
throw error(std::format("unmapped token! {}", (u8)tok.type));
}
auto ARClex(context const* ctx_, preprocessor& ppr) -> parser::symbol_type

View File

@ -321,7 +321,7 @@ decl_constant
: expr_identifier ASSIGN expr SEMICOLON
{
ppr.ban_header(@$); $$ = decl_constant::make(@$, std::move($1), std::move($3));
printf("%s" , fmt::format("{}: constants deprecated, use #define instead\n", @$.print()).data());
printf("%s" , std::format("{}: constants deprecated, use #define instead\n", @$.print()).data());
}
;
@ -496,14 +496,14 @@ stmt_for
stmt_foreach
: FOREACH LPAREN expr_identifier IN expr RPAREN stmt
{
auto array = expr_identifier::make(@$, fmt::format("_temp_{}", ++index));
auto key = expr_identifier::make(@$, fmt::format("_temp_{}", ++index));
auto array = expr_identifier::make(@$, std::format("_temp_{}", ++index));
auto key = expr_identifier::make(@$, std::format("_temp_{}", ++index));
$$ = stmt_foreach::make(@$, std::move($5), std::move($3), expr_empty::make(@$), std::move(array), std::move(key), std::move($7), false);
}
| FOREACH LPAREN expr_identifier COMMA expr_identifier IN expr RPAREN stmt
{
auto array = expr_identifier::make(@$, fmt::format("_temp_{}", ++index));
expr::ptr key = (ctx_->props() & props::foreach) ? expr_identifier::make(@$, fmt::format("_temp_{}", ++index)) : std::move($3);
auto array = expr_identifier::make(@$, std::format("_temp_{}", ++index));
expr::ptr key = (ctx_->props() & props::foreach) ? expr_identifier::make(@$, std::format("_temp_{}", ++index)) : std::move($3);
$$ = stmt_foreach::make(@$, std::move($7), std::move($5), (ctx_->props() & props::foreach) ? std::move($3) : (expr::ptr)expr_empty::make(@$), std::move(array), std::move(key), std::move($9), true);
}
;
@ -821,7 +821,7 @@ expr_tuple
: LBRACKET expr_tuple_arguments RBRACKET
{
$$ = std::move($2);
$$->as<expr_tuple>().temp = expr_identifier::make($$->loc(), fmt::format("_temp_{}", ++index));
$$->as<expr_tuple>().temp = expr_identifier::make($$->loc(), std::format("_temp_{}", ++index));
}
;
@ -1088,7 +1088,7 @@ auto map_token(context const* ctx_, token& tok) -> parser::symbol_type
}
}
throw error(fmt::format("unmapped token! {}", (u8)tok.type));
throw error(std::format("unmapped token! {}", (u8)tok.type));
}
auto GSClex(context const* ctx_, preprocessor& ppr) -> parser::symbol_type

View File

@ -119,12 +119,12 @@ public:
auto print() const -> std::string
{
return fmt::format("{}:{}:{}", *begin.filename, begin.line, begin.column);
return std::format("{}:{}:{}", *begin.filename, begin.line, begin.column);
}
auto label() const -> std::string
{
return fmt::format("loc_{:X}", begin.line);
return std::format("loc_{:X}", begin.line);
}
};

View File

@ -119,12 +119,12 @@ public:
auto print() const -> std::string
{
return fmt::format("{}:{}:{}", *begin.filename, begin.line, begin.column);
return std::format("{}:{}:{}", *begin.filename, begin.line, begin.column);
}
auto label() const -> std::string
{
return fmt::format("loc_{:X}", begin.line);
return std::format("loc_{:X}", begin.line);
}
};

View File

@ -13,6 +13,7 @@
#include <array>
#include <deque>
#include <filesystem>
#include <format>
#include <fstream>
#include <functional>
#include <iostream>
@ -31,13 +32,6 @@
#include <vector>
#include <version>
#ifdef __cpp_lib_format
#include <format>
namespace fmt = std;
#else
#include <fmt/core.h>
#endif
#ifdef _WINDOWS_
#undef ERROR
#undef IN

View File

@ -84,7 +84,7 @@ workspace "gsc-tool"
configurations { "debug", "release" }
if os.istarget("linux") or os.istarget("darwin") then
if os.istarget("linux") or os.istarget("macosx") then
platforms { "x64", "arm64" }
else
platforms { "x86", "x64", "arm64" }
@ -119,23 +119,18 @@ workspace "gsc-tool"
staticruntime "On"
warnings "Extra"
filter { "system:linux", "system:macosx" }
buildoptions "-pthread"
linkoptions "-pthread"
filter "system:linux"
linkoptions "-fuse-ld=lld"
filter {}
if os.istarget("linux") then
filter { "platforms:arm64" }
buildoptions "--target=arm64-linux-gnu"
linkoptions "--target=arm64-linux-gnu"
filter {}
linkoptions "-fuse-ld=lld"
end
filter { "system:linux", "platforms:arm64" }
buildoptions "--target=arm64-linux-gnu"
linkoptions "--target=arm64-linux-gnu"
filter {}
filter { "system:macosx", "platforms:arm64" }
buildoptions "-arch arm64"
linkoptions "-arch arm64"
buildoptions "-arch arm64"
linkoptions "-arch arm64"
filter {}
filter "configurations:release"
@ -178,7 +173,6 @@ project "xsk-tool"
}
cxxopts:link()
fmt:link()
zlib:link()
project "xsk-utils"
@ -195,7 +189,6 @@ project "xsk-utils"
"./include",
}
fmt:include()
zlib:include()
project "xsk-arc"
@ -212,8 +205,6 @@ project "xsk-arc"
"./include",
}
fmt:include()
project "xsk-gsc"
kind "StaticLib"
language "C++"
@ -228,8 +219,5 @@ project "xsk-gsc"
"./include",
}
fmt:include()
group "Dependencies"
zlib:project()
fmt:project()

View File

@ -467,7 +467,7 @@ auto assembler::assemble_instruction(instruction const& inst) -> void
assemble_end_switch(inst);
break;
default:
throw asm_error(fmt::format("unhandled opcode {} at index {:04X}", ctx_->opcode_name(inst.opcode), inst.index));
throw asm_error(std::format("unhandled opcode {} at index {:04X}", ctx_->opcode_name(inst.opcode), inst.index));
}
}
@ -533,7 +533,7 @@ auto assembler::assemble_end_switch(instruction const& inst) -> void
}
else
{
throw asm_error(fmt::format("invalid switch case {}", inst.data[1 + (3 * i)]));
throw asm_error(std::format("invalid switch case {}", inst.data[1 + (3 * i)]));
}
}
}
@ -846,7 +846,7 @@ auto assembler::align_instruction(instruction& inst) -> void
break;
}
default:
throw asm_error(fmt::format("unhandled opcode {} at index {:04X}", ctx_->opcode_name(inst.opcode), inst.index));
throw asm_error(std::format("unhandled opcode {} at index {:04X}", ctx_->opcode_name(inst.opcode), inst.index));
}
}
@ -860,7 +860,7 @@ auto assembler::resolve_label(std::string const& name) -> i32
}
}
throw asm_error(fmt::format("couldn't resolve label address of {}", name));
throw asm_error(std::format("couldn't resolve label address of {}", name));
}
auto assembler::resolve_string(std::string const& name) -> u16
@ -872,7 +872,7 @@ auto assembler::resolve_string(std::string const& name) -> u16
return itr->second;
}
throw asm_error(fmt::format("couldn't resolve string address of {}", name));
throw asm_error(std::format("couldn't resolve string address of {}", name));
}
void assembler::add_stringref(std::string const& str, string_type type, u32 ref)

View File

@ -10,27 +10,27 @@
namespace xsk::arc
{
error::error(std::string const& what) : std::runtime_error(fmt::format("[ERROR]: {}", what))
error::error(std::string const& what) : std::runtime_error(std::format("[ERROR]: {}", what))
{
}
asm_error::asm_error(std::string const& what) : std::runtime_error(fmt::format("[ERROR]:assembler: {}", what))
asm_error::asm_error(std::string const& what) : std::runtime_error(std::format("[ERROR]:assembler: {}", what))
{
}
disasm_error::disasm_error(std::string const& what) : std::runtime_error(fmt::format("[ERROR]:disassembler: {}", what))
disasm_error::disasm_error(std::string const& what) : std::runtime_error(std::format("[ERROR]:disassembler: {}", what))
{
}
ppr_error::ppr_error(location const& loc, std::string const& what) : std::runtime_error(fmt::format("[ERROR]:preprocessor:{}: {}", loc.print(), what))
ppr_error::ppr_error(location const& loc, std::string const& what) : std::runtime_error(std::format("[ERROR]:preprocessor:{}: {}", loc.print(), what))
{
}
comp_error::comp_error(location const& loc, std::string const& what) : std::runtime_error(fmt::format("[ERROR]:compiler:{}: {}", loc.print(), what))
comp_error::comp_error(location const& loc, std::string const& what) : std::runtime_error(std::format("[ERROR]:compiler:{}: {}", loc.print(), what))
{
}
decomp_error::decomp_error(std::string const& what) : std::runtime_error(fmt::format("[ERROR]:decompiler: {}", what))
decomp_error::decomp_error(std::string const& what) : std::runtime_error(std::format("[ERROR]:decompiler: {}", what))
{
}

View File

@ -49,7 +49,7 @@ auto compiler::emit_program(program const& prog) -> void
for (auto const& entry : localfuncs_)
{
if (entry == name)
throw comp_error(dec->loc(), fmt::format("function name '{}' already defined as local function", name));
throw comp_error(dec->loc(), std::format("function name '{}' already defined as local function", name));
}
localfuncs_.push_back(dec->as<decl_function>().name->value);
@ -70,7 +70,7 @@ auto compiler::emit_include(include const& inc) -> void
{
if (entry == path)
{
throw comp_error(inc.loc(), fmt::format("duplicated include file {}", path));
throw comp_error(inc.loc(), std::format("duplicated include file {}", path));
}
}
@ -322,7 +322,7 @@ auto compiler::emit_stmt_waittill(stmt_waittill const& stm) -> void
if (entry->is<expr_undefined>())
emit_opcode(opcode::OP_SafeDecTop);
else
emit_opcode(opcode::OP_SafeSetWaittillVariableFieldCached, fmt::format("{}", variable_access(entry->as<expr_identifier>())));
emit_opcode(opcode::OP_SafeSetWaittillVariableFieldCached, std::format("{}", variable_access(entry->as<expr_identifier>())));
}
emit_opcode(opcode::OP_ClearParams);
@ -333,7 +333,7 @@ auto compiler::emit_stmt_waittillmatch(stmt_waittillmatch const& stm) -> void
emit_expr_arguments(*stm.args);
emit_expr(*stm.event);
emit_expr(*stm.obj);
emit_opcode(opcode::OP_WaitTillMatch, fmt::format("{}", stm.args->list.size()));
emit_opcode(opcode::OP_WaitTillMatch, std::format("{}", stm.args->list.size()));
emit_opcode(opcode::OP_ClearParams);
}
@ -527,7 +527,7 @@ auto compiler::emit_stmt_foreach(stmt_foreach const& stm) -> void
can_continue_ = true;
emit_expr_variable(*stm.key);
emit_opcode(opcode::OP_EvalLocalVariableCached, fmt::format("{}", variable_access(stm.array->as<expr_identifier>())));
emit_opcode(opcode::OP_EvalLocalVariableCached, std::format("{}", variable_access(stm.array->as<expr_identifier>())));
emit_opcode(opcode::OP_EvalArray);
emit_expr_variable_ref(*stm.value, true);
@ -565,7 +565,7 @@ auto compiler::emit_stmt_switch(stmt_switch const& stm) -> void
can_break_ = true;
auto data = std::vector<std::string>{};
data.push_back(fmt::format("{}", stm.body->block->list.size()));
data.push_back(std::format("{}", stm.body->block->list.size()));
auto type = switch_type::none;
auto loc_default = std::string{};
@ -635,7 +635,7 @@ auto compiler::emit_stmt_switch(stmt_switch const& stm) -> void
data.push_back(loc_default);
}
data.push_back(fmt::format("{}", static_cast<std::underlying_type_t<switch_type>>(type)));
data.push_back(std::format("{}", static_cast<std::underlying_type_t<switch_type>>(type)));
insert_label(table_loc);
emit_opcode(opcode::OP_EndSwitch, data);
@ -863,10 +863,10 @@ auto compiler::emit_expr_const(expr_const const& exp) -> void
auto const itr = constants_.find(exp.lvalue->value);
if (itr != constants_.end())
throw comp_error(exp.loc(), fmt::format("duplicated constant '{}'", exp.lvalue->value));
throw comp_error(exp.loc(), std::format("duplicated constant '{}'", exp.lvalue->value));
if (std::find(stackframe_.begin(), stackframe_.end(), exp.lvalue->value) != stackframe_.end())
throw comp_error(exp.loc(), fmt::format("constant already defined as local variable '{}'", exp.lvalue->value));
throw comp_error(exp.loc(), std::format("constant already defined as local variable '{}'", exp.lvalue->value));
constants_.insert({ exp.lvalue->value, exp.rvalue.get() });
}
@ -1120,7 +1120,7 @@ auto compiler::emit_expr_call_pointer(expr_pointer const& exp, bool is_stmt) ->
emit_expr_arguments(*exp.args);
emit_expr(*exp.func);
auto argcount = fmt::format("{}", exp.args->list.size());
auto argcount = std::format("{}", exp.args->list.size());
switch (exp.mode)
{
@ -1173,18 +1173,18 @@ auto compiler::emit_expr_call_function(expr_function const& exp, bool is_stmt) -
emit_opcode(opcode::OP_PreScriptCall);
emit_expr_arguments(*exp.args);
auto argcount = fmt::format("{}", exp.args->list.size());
auto argcount = std::format("{}", exp.args->list.size());
auto flags = developer_thread_ ? static_cast<u8>(import_flags::developer) : 0;
switch (exp.mode)
{
case call::mode::normal:
flags |= static_cast<u8>(import_flags::func_call);
emit_opcode(opcode::OP_ScriptFunctionCall, { exp.path->value, exp.name->value, argcount, fmt::format("{}", flags) });
emit_opcode(opcode::OP_ScriptFunctionCall, { exp.path->value, exp.name->value, argcount, std::format("{}", flags) });
break;
case call::mode::thread:
flags |= static_cast<u8>(import_flags::func_call_thread);
emit_opcode(opcode::OP_ScriptThreadCall, { exp.path->value, exp.name->value, argcount, fmt::format("{}", flags) });
emit_opcode(opcode::OP_ScriptThreadCall, { exp.path->value, exp.name->value, argcount, std::format("{}", flags) });
break;
default:
break;
@ -1217,7 +1217,7 @@ auto compiler::emit_expr_method_pointer(expr_pointer const& exp, expr const& obj
emit_expr(obj);
emit_expr(*exp.func);
auto argcount = fmt::format("{}", exp.args->list.size());
auto argcount = std::format("{}", exp.args->list.size());
switch (exp.mode)
{
@ -1260,18 +1260,18 @@ auto compiler::emit_expr_method_function(expr_function const& exp, expr const& o
emit_expr_arguments(*exp.args);
emit_expr(obj);
auto argcount = fmt::format("{}", exp.args->list.size());
auto argcount = std::format("{}", exp.args->list.size());
auto flags = developer_thread_ ? static_cast<u8>(import_flags::developer) : 0;
switch (exp.mode)
{
case call::mode::normal:
flags |= static_cast<u8>(import_flags::meth_call);
emit_opcode(opcode::OP_ScriptMethodCall, { exp.path->value, exp.name->value, argcount, fmt::format("{}", flags) });
emit_opcode(opcode::OP_ScriptMethodCall, { exp.path->value, exp.name->value, argcount, std::format("{}", flags) });
break;
case call::mode::thread:
flags |= static_cast<u8>(import_flags::meth_call_thread);
emit_opcode(opcode::OP_ScriptMethodThreadCall, { exp.path->value, exp.name->value, argcount, fmt::format("{}", flags) });
emit_opcode(opcode::OP_ScriptMethodThreadCall, { exp.path->value, exp.name->value, argcount, std::format("{}", flags) });
break;
default:
break;
@ -1456,7 +1456,7 @@ auto compiler::emit_expr_reference(expr_reference const& exp) -> void
auto flags = developer_thread_ ? static_cast<u8>(import_flags::developer) : 0;
flags |= static_cast<u8>(import_flags::func_reference);
emit_opcode(opcode::OP_GetFunction, { exp.path->value, exp.name->value, "0", fmt::format("{}", flags) });
emit_opcode(opcode::OP_GetFunction, { exp.path->value, exp.name->value, "0", std::format("{}", flags) });
}
auto compiler::emit_expr_size(expr_size const& exp) -> void
@ -1542,7 +1542,7 @@ auto compiler::emit_expr_field_ref(expr_field const& exp, bool set) -> void
if (set) emit_opcode(opcode::OP_SetVariableField);
break;
case node::expr_identifier:
emit_opcode(opcode::OP_EvalLocalVariableCached, fmt::format("{}", variable_access(exp.obj->as<expr_identifier>())));
emit_opcode(opcode::OP_EvalLocalVariableCached, std::format("{}", variable_access(exp.obj->as<expr_identifier>())));
emit_opcode(opcode::OP_CastFieldObject);
emit_opcode(opcode::OP_EvalFieldVariableRef, field);
if (set) emit_opcode(opcode::OP_SetVariableField);
@ -1570,10 +1570,10 @@ auto compiler::emit_expr_local_ref(expr_identifier const& exp, bool set) -> void
if (it != constants_.end())
{
throw comp_error(exp.loc(), fmt::format("variable name already defined as constant '{}'", exp.value));
throw comp_error(exp.loc(), std::format("variable name already defined as constant '{}'", exp.value));
}
emit_opcode(opcode::OP_EvalLocalVariableRefCached, fmt::format("{}", variable_access(exp)));
emit_opcode(opcode::OP_EvalLocalVariableRefCached, std::format("{}", variable_access(exp)));
if (set)
{
@ -1645,7 +1645,7 @@ auto compiler::emit_expr_field(expr_field const& exp) -> void
emit_opcode(opcode::OP_EvalFieldVariable, field);
break;
case node::expr_identifier:
emit_opcode(opcode::OP_EvalLocalVariableCached, fmt::format("{}", variable_access(exp.obj->as<expr_identifier>())));
emit_opcode(opcode::OP_EvalLocalVariableCached, std::format("{}", variable_access(exp.obj->as<expr_identifier>())));
emit_opcode(opcode::OP_CastFieldObject);
emit_opcode(opcode::OP_EvalFieldVariable, field);
break;
@ -1661,7 +1661,7 @@ auto compiler::emit_expr_local(expr_identifier const& exp) -> void
if (it != constants_.end())
emit_expr(*it->second);
else
emit_opcode(opcode::OP_EvalLocalVariableCached, fmt::format("{}", variable_access(exp)));
emit_opcode(opcode::OP_EvalLocalVariableCached, std::format("{}", variable_access(exp)));
}
auto compiler::emit_expr_object(expr const& exp) -> void
@ -1694,7 +1694,7 @@ auto compiler::emit_expr_object(expr const& exp) -> void
emit_opcode(opcode::OP_CastFieldObject);
break;
case node::expr_identifier:
emit_opcode(opcode::OP_EvalLocalVariableCached, fmt::format("{}", variable_access(exp.as<expr_identifier>())));
emit_opcode(opcode::OP_EvalLocalVariableCached, std::format("{}", variable_access(exp.as<expr_identifier>())));
emit_opcode(opcode::OP_CastFieldObject);
break;
default:
@ -1785,7 +1785,7 @@ auto compiler::emit_expr_vector(expr_vector const& exp) -> void
if (isconst)
{
emit_opcode(opcode::OP_VectorConstant, fmt::format("{}", flags));
emit_opcode(opcode::OP_VectorConstant, std::format("{}", flags));
}
else
{
@ -2156,7 +2156,7 @@ auto compiler::variable_access(expr_identifier const& exp) -> u8
}
}
throw comp_error(exp.loc(), fmt::format("local variable '{}' not found", exp.value));
throw comp_error(exp.loc(), std::format("local variable '{}' not found", exp.value));
}
auto compiler::is_constant_condition(expr const& exp) -> bool
@ -2227,7 +2227,7 @@ auto compiler::insert_label() -> std::string
else
{
label_idx_++;
auto name = fmt::format("loc_{}", label_idx_);
auto name = std::format("loc_{}", label_idx_);
function_->labels.insert({ index_, name });
return name;
}
@ -2236,7 +2236,7 @@ auto compiler::insert_label() -> std::string
auto compiler::create_label() -> std::string
{
label_idx_++;
return fmt::format("loc_{}", label_idx_);
return std::format("loc_{}", label_idx_);
}
} // namespace xsk::arc

View File

@ -206,7 +206,7 @@ auto context::opcode_size(opcode op) const -> u32
case opcode::OP_GetVector:
return (props_ & props::size64) ? 14 : 13;
default:
throw error(fmt::format("couldn't resolve instruction size for '{}'", opcode_name(op)));
throw error(std::format("couldn't resolve instruction size for '{}'", opcode_name(op)));
}
}
@ -219,7 +219,7 @@ auto context::opcode_id(opcode op) const -> u16
return itr->second;
}
throw error(fmt::format("couldn't resolve opcode id for '{}'", opcode_name(op)));
throw error(std::format("couldn't resolve opcode id for '{}'", opcode_name(op)));
}
auto context::opcode_name(opcode op) const -> std::string
@ -231,7 +231,7 @@ auto context::opcode_name(opcode op) const -> std::string
return std::string{ itr->second };
}
throw std::runtime_error(fmt::format("couldn't resolve opcode string for enum '{}'", static_cast<std::underlying_type_t<opcode>>(op)));
throw std::runtime_error(std::format("couldn't resolve opcode string for enum '{}'", static_cast<std::underlying_type_t<opcode>>(op)));
}
auto context::opcode_enum(std::string const& name) const -> opcode
@ -243,7 +243,7 @@ auto context::opcode_enum(std::string const& name) const -> opcode
return itr->second;
}
throw std::runtime_error(fmt::format("couldn't resolve opcode enum for name '{}'", name));
throw std::runtime_error(std::format("couldn't resolve opcode enum for name '{}'", name));
}
auto context::opcode_enum(u16 id) const -> opcode
@ -302,7 +302,7 @@ auto context::hash_name(u32 id) const -> std::string
return std::string(itr->second);
}
return fmt::format("_id_{:08X}", id);
return std::format("_id_{:08X}", id);
}
auto context::make_token(std::string_view str) const -> std::string
@ -344,7 +344,7 @@ auto context::load_header(std::string const& name) -> std::tuple<std::string con
}
}
throw error(fmt::format("couldn't open gsh file '{}'", name));
throw error(std::format("couldn't open gsh file '{}'", name));
}
extern std::array<std::pair<opcode, std::string_view>, opcode_count> const opcode_list

View File

@ -86,7 +86,7 @@ auto decompiler::decompile_function(function const& func) -> void
}
auto& list = func_->body->block->list;
locs_.end = fmt::format("loc_{:X}", list.back()->loc().begin.line + 1);
locs_.end = std::format("loc_{:X}", list.back()->loc().begin.line + 1);
decompile_statements(*func_->body->block);
@ -1137,7 +1137,7 @@ auto decompiler::decompile_instruction(instruction const& inst, bool last) -> vo
case opcode::OP_EvalLocalVariableCachedDebug:
case opcode::OP_EvalLocalVariableRefCachedDebug:
default:
throw decomp_error(fmt::format("unhandled opcode {}", ctx_->opcode_name(inst.opcode)));
throw decomp_error(std::format("unhandled opcode {}", ctx_->opcode_name(inst.opcode)));
}
}
@ -1933,7 +1933,7 @@ auto decompiler::find_location_index(stmt_list const& stm, std::string const& lo
index++;
}
throw decomp_error(fmt::format("location '{}' not found", loc));
throw decomp_error(std::format("location '{}' not found", loc));
}
auto decompiler::last_location_index(stmt_list const& stm, usize index) -> bool
@ -1992,7 +1992,7 @@ auto decompiler::resolve_label(std::string const& name) -> u32
}
}
throw decomp_error(fmt::format("couldn't resolve label address of '{}'", name));
throw decomp_error(std::format("couldn't resolve label address of '{}'", name));
}
auto decompiler::process_function(decl_function& func) -> void

View File

@ -476,17 +476,17 @@ auto disassembler::disassemble_instruction(instruction& inst) -> void
break;
case opcode::OP_GetByte:
case opcode::OP_GetNegByte:
inst.data.push_back(fmt::format("{}", script_.read<u8>()));
inst.data.push_back(std::format("{}", script_.read<u8>()));
break;
case opcode::OP_GetUnsignedShort:
case opcode::OP_GetNegUnsignedShort:
inst.size += script_.align(2);
inst.data.push_back(fmt::format("{}", script_.read<u16>()));
inst.data.push_back(std::format("{}", script_.read<u16>()));
break;
case opcode::OP_GetInteger:
inst.size += script_.align(4);
disassemble_animtree(inst);
inst.data.push_back(fmt::format("{}", script_.read<i32>()));
inst.data.push_back(std::format("{}", script_.read<i32>()));
break;
case opcode::OP_GetFloat:
inst.size += script_.align(4);
@ -496,7 +496,7 @@ auto disassembler::disassemble_instruction(instruction& inst) -> void
//case opcode::OP_ProfileStart:
case opcode::OP_GetAPIFunction:
inst.size += script_.align(8);
inst.data.push_back(fmt::format("0x{:016X}", script_.read<u64>()));
inst.data.push_back(std::format("0x{:016X}", script_.read<u64>()));
break;
case opcode::OP_GetVector:
inst.size += script_.align(4);
@ -512,10 +512,10 @@ auto disassembler::disassemble_instruction(instruction& inst) -> void
disassemble_animation(inst);
break;
case opcode::OP_WaitTillMatch:
inst.data.push_back(fmt::format("{}", script_.read<u8>()));
inst.data.push_back(std::format("{}", script_.read<u8>()));
break;
case opcode::OP_VectorConstant:
inst.data.push_back(fmt::format("{}", script_.read<u8>()));
inst.data.push_back(std::format("{}", script_.read<u8>()));
break;
case opcode::OP_GetHash:
inst.size += script_.align(4);
@ -535,7 +535,7 @@ auto disassembler::disassemble_instruction(instruction& inst) -> void
case opcode::OP_EvalLocalArrayRefCached:
case opcode::OP_SafeSetWaittillVariableFieldCached:
case opcode::OP_EvalLocalVariableRefCached:
inst.data.push_back(fmt::format("{}", script_.read<u8>()));
inst.data.push_back(std::format("{}", script_.read<u8>()));
break;
case opcode::OP_EvalFieldVariable:
case opcode::OP_EvalFieldVariableRef:
@ -553,7 +553,7 @@ auto disassembler::disassemble_instruction(instruction& inst) -> void
case opcode::OP_ScriptMethodCallPointer:
case opcode::OP_ScriptThreadCallPointer:
case opcode::OP_ScriptMethodThreadCallPointer:
inst.data.push_back(fmt::format("{}", script_.read<u8>()));
inst.data.push_back(std::format("{}", script_.read<u8>()));
break;
case opcode::OP_GetFunction:
disassemble_import(inst);
@ -583,7 +583,7 @@ auto disassembler::disassemble_instruction(instruction& inst) -> void
disassemble_end_switch(inst);
break;
default:
throw disasm_error(fmt::format("unhandled opcode {} at index {:04X}", ctx_->opcode_name(inst.opcode), inst.index));
throw disasm_error(std::format("unhandled opcode {} at index {:04X}", ctx_->opcode_name(inst.opcode), inst.index));
}
}
@ -606,7 +606,7 @@ auto disassembler::disassemble_name(instruction& inst) -> void
return;
}
throw disasm_error(fmt::format("string reference not found at index {:04X}", inst.index));
throw disasm_error(std::format("string reference not found at index {:04X}", inst.index));
}
}
@ -620,7 +620,7 @@ auto disassembler::disassemble_params(instruction& inst) -> void
{
inst.size += script_.align(4) + 5;
inst.data.push_back(ctx_->hash_name(script_.read<u32>()));
inst.data.push_back(fmt::format("{}", script_.read<u8>()));
inst.data.push_back(std::format("{}", script_.read<u8>()));
}
else
{
@ -644,7 +644,7 @@ auto disassembler::disassemble_import(instruction& inst) -> void
return;
}
throw disasm_error(fmt::format("import reference not found at index {:04X}", inst.index));
throw disasm_error(std::format("import reference not found at index {:04X}", inst.index));
}
auto disassembler::disassemble_string(instruction& inst) -> void
@ -660,7 +660,7 @@ auto disassembler::disassemble_string(instruction& inst) -> void
return;
}
throw disasm_error(fmt::format("string reference not found at index {:04X}", inst.index));
throw disasm_error(std::format("string reference not found at index {:04X}", inst.index));
}
auto disassembler::disassemble_animtree(instruction& inst) -> void
@ -695,7 +695,7 @@ auto disassembler::disassemble_animation(instruction& inst) -> void
}
}
throw disasm_error(fmt::format("animation reference not found at index {:04X}", inst.index));
throw disasm_error(std::format("animation reference not found at index {:04X}", inst.index));
}
auto disassembler::disassemble_jump(instruction& inst) -> void
@ -709,7 +709,7 @@ auto disassembler::disassemble_jump(instruction& inst) -> void
else
addr = script_.read<i16>() + script_.pos();
auto const label = fmt::format("loc_{:X}", addr);
auto const label = std::format("loc_{:X}", addr);
inst.data.push_back(label);
func_->labels.insert({ addr, label });
@ -720,7 +720,7 @@ auto disassembler::disassemble_switch(instruction& inst) -> void
inst.size += script_.align(4);
auto const addr = script_.read<i32>() + script_.pos();
auto const label = fmt::format("loc_{:X}", addr);
auto const label = std::format("loc_{:X}", addr);
inst.data.push_back(label);
func_->labels.insert({ addr, label });
@ -738,7 +738,7 @@ auto disassembler::disassemble_end_switch(instruction& inst) -> void
{
if (entry->opcode == opcode::OP_Switch && entry->data[0] == itr->second)
{
auto const label = fmt::format("loc_{:X}", inst.index);
auto const label = std::format("loc_{:X}", inst.index);
entry->data[0] = label;
func_->labels.erase(script_.pos());
@ -754,7 +754,7 @@ auto disassembler::disassemble_end_switch(instruction& inst) -> void
auto type = switch_type::none;
auto const count = script_.read<u32>();
inst.data.push_back(fmt::format("{}", count));
inst.data.push_back(std::format("{}", count));
for (auto i = 0u; i < count; i++)
{
@ -777,7 +777,7 @@ auto disassembler::disassemble_end_switch(instruction& inst) -> void
{
type = switch_type::integer;
inst.data.push_back("case");
inst.data.push_back(fmt::format("{}", value));
inst.data.push_back(std::format("{}", value));
}
}
else
@ -798,12 +798,12 @@ auto disassembler::disassemble_end_switch(instruction& inst) -> void
{
type = switch_type::integer;
inst.data.push_back("case");
inst.data.push_back(fmt::format("{}", (value - 0x800000) & 0xFFFFFF));
inst.data.push_back(std::format("{}", (value - 0x800000) & 0xFFFFFF));
}
}
auto const addr = script_.read<i32>() + script_.pos();
auto const label = fmt::format("loc_{:X}", addr);
auto const label = std::format("loc_{:X}", addr);
inst.data.push_back(label);
func_->labels.insert({ addr, label });
@ -811,7 +811,7 @@ auto disassembler::disassemble_end_switch(instruction& inst) -> void
inst.size += 8;
}
inst.data.push_back(fmt::format("{}", static_cast<std::underlying_type_t<switch_type>>(type)));
inst.data.push_back(std::format("{}", static_cast<std::underlying_type_t<switch_type>>(type)));
}
} // namespace xsk::arc

View File

@ -327,7 +327,7 @@ auto lexer::lex() -> token
else if (last == '_' || (last >= 'A' && last <= 'Z') || (last >= 'a' && last <= 'z'))
goto lex_name;
throw comp_error(loc_, fmt::format("bad token: '{}'", last));
throw comp_error(loc_, std::format("bad token: '{}'", last));
}
lex_string:

View File

@ -1807,7 +1807,7 @@ namespace xsk { namespace arc {
int yylen = 0;
// Error handling.
int yynerrs_ = 0;
[[maybe_unused]] int yynerrs_ = 0;
int yyerrstatus_ = 0;
/// The lookahead symbol.
@ -2836,8 +2836,8 @@ namespace xsk { namespace arc {
case 87: // stmt_foreach: "foreach" "(" expr_identifier "in" expr ")" stmt
#line 519 "parser.ypp"
{
auto array = expr_identifier::make(yylhs.location, fmt::format("_a{}", ++index));
auto key = expr_identifier::make(yylhs.location, fmt::format("_k{}", ++index));
auto array = expr_identifier::make(yylhs.location, std::format("_a{}", ++index));
auto key = expr_identifier::make(yylhs.location, std::format("_k{}", ++index));
yylhs.value.as < stmt_foreach::ptr > () = stmt_foreach::make(yylhs.location, std::move(yystack_[2].value.as < expr::ptr > ()), std::move(yystack_[4].value.as < expr_identifier::ptr > ()), std::move(array), std::move(key), std::move(yystack_[0].value.as < stmt::ptr > ()), false);
}
#line 2850 "parser.cpp"
@ -2846,7 +2846,7 @@ namespace xsk { namespace arc {
case 88: // stmt_foreach: "foreach" "(" expr_identifier "," expr_identifier "in" expr ")" stmt
#line 525 "parser.ypp"
{
auto array = expr_identifier::make(yylhs.location, fmt::format("_a{}", ++index));
auto array = expr_identifier::make(yylhs.location, std::format("_a{}", ++index));
yylhs.value.as < stmt_foreach::ptr > () = stmt_foreach::make(yylhs.location, std::move(yystack_[2].value.as < expr::ptr > ()), std::move(yystack_[4].value.as < expr_identifier::ptr > ()), std::move(array), std::move(yystack_[6].value.as < expr_identifier::ptr > ()), std::move(yystack_[0].value.as < stmt::ptr > ()), true);
}
#line 2859 "parser.cpp"
@ -5609,7 +5609,7 @@ auto map_token(context const* ctx_, token& tok) -> parser::symbol_type
}
}
throw error(fmt::format("unmapped token! {}", (u8)tok.type));
throw error(std::format("unmapped token! {}", (u8)tok.type));
}
auto ARClex(context const* ctx_, preprocessor& ppr) -> parser::symbol_type

View File

@ -97,12 +97,12 @@ auto preprocessor::push_header(std::string const& file) -> void
{
try
{
auto name = fmt::format("{}.gsh", file);
auto name = std::format("{}.gsh", file);
for (auto& inc : includes_)
{
if (inc == name)
throw ppr_error(location{}, fmt::format("recursive header inclusion {} at {}", name, includes_.back()));
throw ppr_error(location{}, std::format("recursive header inclusion {} at {}", name, includes_.back()));
}
auto data = ctx_->load_header(name);
@ -112,7 +112,7 @@ auto preprocessor::push_header(std::string const& file) -> void
}
catch (std::exception const& e)
{
throw error(fmt::format("parsing header file '{}': {}", file, e.what()));
throw error(std::format("parsing header file '{}': {}", file, e.what()));
}
}
@ -252,7 +252,7 @@ auto preprocessor::read_directive(token& tok) -> void
}
}
throw ppr_error(next.pos, fmt::format("invalid preprocessing directive '{}'", next.data));
throw ppr_error(next.pos, std::format("invalid preprocessing directive '{}'", next.data));
}
auto preprocessor::read_directive_if(token&) -> void
@ -763,7 +763,7 @@ auto preprocessor::expand(token& tok, define& def) -> void
}
else if (tok.data == "__LINE__")
{
tokens_.push_front(token{ token::STRING, tok.space, tok.pos, fmt::format("{}", tok.pos.begin.line) });
tokens_.push_front(token{ token::STRING, tok.space, tok.pos, std::format("{}", tok.pos.begin.line) });
}
else if (tok.data == "__DATE__")
{
@ -942,7 +942,7 @@ auto preprocessor::expect(token& tok, token::kind expected, spacing) -> void
{
if (tok.type != expected)
{
throw ppr_error(tok.pos, fmt::format("expected {} found {}", (u8)expected, (u8)tok.type));
throw ppr_error(tok.pos, std::format("expected {} found {}", (u8)expected, (u8)tok.type));
}
}
@ -1095,7 +1095,7 @@ auto preprocessor::eval_consume(token::kind type, std::string_view msg)
{
if (eval_check(type)) return eval_next();
throw ppr_error(eval_peek().pos, fmt::format("{}", msg));
throw ppr_error(eval_peek().pos, std::format("{}", msg));
}
auto preprocessor::eval_expr() -> i32

File diff suppressed because it is too large Load Diff

View File

@ -326,7 +326,7 @@ auto assembler::assemble_instruction(instruction const& inst) -> void
assemble_formal_params(inst);
break;
default:
throw asm_error(fmt::format("unhandled opcode {} at index {:04X}", ctx_->opcode_name(inst.opcode), inst.index));
throw asm_error(std::format("unhandled opcode {} at index {:04X}", ctx_->opcode_name(inst.opcode), inst.index));
}
}
@ -339,7 +339,7 @@ auto assembler::assemble_builtin_call(instruction const& inst, bool method, bool
if (ctx_->props() & props::hash)
{
stack_.write_cstr(fmt::format("#xS{:x}", ctx_->hash_id(inst.data[0])));
stack_.write_cstr(std::format("#xS{:x}", ctx_->hash_id(inst.data[0])));
script_.write<u16>(0);
}
else
@ -477,7 +477,7 @@ auto assembler::assemble_end_switch(instruction const& inst) -> void
}
else
{
throw asm_error(fmt::format("invalid switch case {}", inst.data[1 + (4 * i)]));
throw asm_error(std::format("invalid switch case {}", inst.data[1 + (4 * i)]));
}
}
else
@ -513,7 +513,7 @@ auto assembler::assemble_end_switch(instruction const& inst) -> void
}
else
{
throw asm_error(fmt::format("invalid switch case {}", inst.data[1 + (3 * i)]));
throw asm_error(std::format("invalid switch case {}", inst.data[1 + (3 * i)]));
}
}
}
@ -619,7 +619,7 @@ auto assembler::resolve_function(std::string const& name) -> std::int32_t
}
}
throw asm_error(fmt::format("couldn't resolve local function address of {}", name));
throw asm_error(std::format("couldn't resolve local function address of {}", name));
}
auto assembler::resolve_label(std::string const& name) -> std::int32_t
@ -632,7 +632,7 @@ auto assembler::resolve_label(std::string const& name) -> std::int32_t
}
}
throw asm_error(fmt::format("couldn't resolve label address of {}", name));
throw asm_error(std::format("couldn't resolve label address of {}", name));
}
auto assembler::encrypt_string(std::string const& str) -> std::string

View File

@ -10,27 +10,27 @@
namespace xsk::gsc
{
error::error(std::string const& what) : std::runtime_error(fmt::format("[ERROR]: {}", what))
error::error(std::string const& what) : std::runtime_error(std::format("[ERROR]: {}", what))
{
}
asm_error::asm_error(std::string const& what) : std::runtime_error(fmt::format("[ERROR]:assembler: {}", what))
asm_error::asm_error(std::string const& what) : std::runtime_error(std::format("[ERROR]:assembler: {}", what))
{
}
disasm_error::disasm_error(std::string const& what) : std::runtime_error(fmt::format("[ERROR]:disassembler: {}", what))
disasm_error::disasm_error(std::string const& what) : std::runtime_error(std::format("[ERROR]:disassembler: {}", what))
{
}
ppr_error::ppr_error(location const& loc, std::string const& what) : std::runtime_error(fmt::format("[ERROR]:preprocessor:{}: {}", loc.print(), what))
ppr_error::ppr_error(location const& loc, std::string const& what) : std::runtime_error(std::format("[ERROR]:preprocessor:{}: {}", loc.print(), what))
{
}
comp_error::comp_error(location const& loc, std::string const& what) : std::runtime_error(fmt::format("[ERROR]:compiler:{}: {}", loc.print(), what))
comp_error::comp_error(location const& loc, std::string const& what) : std::runtime_error(std::format("[ERROR]:compiler:{}: {}", loc.print(), what))
{
}
decomp_error::decomp_error(std::string const& what) : std::runtime_error(fmt::format("[ERROR]:decompiler: {}", what))
decomp_error::decomp_error(std::string const& what) : std::runtime_error(std::format("[ERROR]:decompiler: {}", what))
{
}

View File

@ -45,7 +45,7 @@ auto compiler::emit_program(program const& prog) -> void
if (!ctx_->load_include(path))
{
throw error(fmt::format("duplicated include file {}", path));
throw error(std::format("duplicated include file {}", path));
}
}
@ -57,13 +57,13 @@ auto compiler::emit_program(program const& prog) -> void
if (ctx_->func_exists(name) || ctx_->meth_exists(name))
{
throw comp_error(dec->loc(), fmt::format("function name '{}' already defined as builtin", name));
throw comp_error(dec->loc(), std::format("function name '{}' already defined as builtin", name));
}
for (auto const& entry : localfuncs_)
{
if (entry == name)
throw comp_error(dec->loc(), fmt::format("function name '{}' already defined as local function", name));
throw comp_error(dec->loc(), std::format("function name '{}' already defined as local function", name));
}
localfuncs_.push_back(dec->as<decl_function>().name->value);
@ -114,7 +114,7 @@ auto compiler::emit_decl_constant(decl_constant const& constant) -> void
auto const it = constants_.find(constant.name->value);
if (it != constants_.end())
throw comp_error(constant.loc(), fmt::format("duplicated constant '{}'", constant.name->value));
throw comp_error(constant.loc(), std::format("duplicated constant '{}'", constant.name->value));
constants_.insert({ constant.name->value, constant.value.get() });
}
@ -323,7 +323,7 @@ auto compiler::emit_stmt_waittill(stmt_waittill const& stm, scope& scp) -> void
for (auto const& entry : stm.args->list)
{
emit_opcode(opcode::OP_SafeSetWaittillVariableFieldCached, fmt::format("{}", variable_create(entry->as<expr_identifier>(), scp)));
emit_opcode(opcode::OP_SafeSetWaittillVariableFieldCached, std::format("{}", variable_create(entry->as<expr_identifier>(), scp)));
}
emit_opcode(opcode::OP_clearparams);
@ -334,7 +334,7 @@ auto compiler::emit_stmt_waittillmatch(stmt_waittillmatch const& stm, scope& scp
emit_expr_arguments(*stm.args, scp);
emit_expr(*stm.event, scp);
emit_expr(*stm.obj, scp);
emit_opcode(opcode::OP_waittillmatch, fmt::format("{}", stm.args->list.size()));
emit_opcode(opcode::OP_waittillmatch, std::format("{}", stm.args->list.size()));
emit_opcode(opcode::OP_waittillmatch2);
emit_opcode(opcode::OP_clearparams);
}
@ -676,7 +676,7 @@ auto compiler::emit_stmt_foreach(stmt_foreach const& stm, scope& scp) -> void
can_continue_ = true;
emit_expr_variable(*stm.key, *scp_body);
emit_opcode(opcode::OP_EvalLocalArrayCached, fmt::format("{}", variable_access(stm.array->as<expr_identifier>(), *scp_body)));
emit_opcode(opcode::OP_EvalLocalArrayCached, std::format("{}", variable_access(stm.array->as<expr_identifier>(), *scp_body)));
emit_expr_variable_ref(*stm.value, *scp_body, true);
if (ctx_->props() & props::foreach && stm.use_key)
@ -734,7 +734,7 @@ auto compiler::emit_stmt_switch(stmt_switch const& stm, scope& scp) -> void
can_break_ = true;
auto data = std::vector<std::string>{};
data.push_back(fmt::format("{}", stm.body->block->list.size()));
data.push_back(std::format("{}", stm.body->block->list.size()));
auto type = switch_type::none;
auto loc_default = std::string{};
@ -753,7 +753,7 @@ auto compiler::emit_stmt_switch(stmt_switch const& stm, scope& scp) -> void
{
if (ctx_->engine() == engine::iw9)
{
data.push_back(fmt::format("{}", static_cast<std::underlying_type_t<switch_type>>(switch_type::integer)));
data.push_back(std::format("{}", static_cast<std::underlying_type_t<switch_type>>(switch_type::integer)));
}
else
{
@ -772,7 +772,7 @@ auto compiler::emit_stmt_switch(stmt_switch const& stm, scope& scp) -> void
{
if (ctx_->engine() == engine::iw9)
{
data.push_back(fmt::format("{}", static_cast<std::underlying_type_t<switch_type>>(switch_type::string)));
data.push_back(std::format("{}", static_cast<std::underlying_type_t<switch_type>>(switch_type::string)));
}
else
{
@ -834,7 +834,7 @@ auto compiler::emit_stmt_switch(stmt_switch const& stm, scope& scp) -> void
scp.init(break_blks_);
}
data.push_back(fmt::format("{}", static_cast<std::underlying_type_t<switch_type>>(type)));
data.push_back(std::format("{}", static_cast<std::underlying_type_t<switch_type>>(type)));
insert_label(table_loc);
@ -1128,7 +1128,7 @@ auto compiler::emit_expr_clear_local(expr_identifier const& exp, scope& scp) ->
if (index == 0)
emit_opcode(opcode::OP_ClearLocalVariableFieldCached0);
else
emit_opcode(opcode::OP_ClearLocalVariableFieldCached, fmt::format("{}", index));
emit_opcode(opcode::OP_ClearLocalVariableFieldCached, std::format("{}", index));
}
auto compiler::emit_expr_increment(expr_increment const& exp, scope& scp, bool is_stmt) -> void
@ -1323,7 +1323,7 @@ auto compiler::emit_expr_call_pointer(expr_pointer const& exp, scope& scp, bool
emit_expr_arguments(*exp.args, scp);
emit_expr(*exp.func, scp);
auto argcount = fmt::format("{}", exp.args->list.size());
auto argcount = std::format("{}", exp.args->list.size());
switch (exp.mode)
{
@ -1360,7 +1360,7 @@ auto compiler::emit_expr_call_function(expr_function const& exp, scope& scp, boo
emit_expr_arguments(*exp.args, scp);
auto argcount = fmt::format("{}", exp.args->list.size());
auto argcount = std::format("{}", exp.args->list.size());
if (type == call::type::local)
{
@ -1465,7 +1465,7 @@ auto compiler::emit_expr_method_pointer(expr_pointer const& exp, expr const& obj
emit_expr(obj, scp);
emit_expr(*exp.func, scp);
auto argcount = fmt::format("{}", exp.args->list.size());
auto argcount = std::format("{}", exp.args->list.size());
switch (exp.mode)
{
@ -1503,7 +1503,7 @@ auto compiler::emit_expr_method_function(expr_function const& exp, expr const& o
emit_expr_arguments(*exp.args, scp);
emit_expr(obj, scp);
auto argcount = fmt::format("{}", exp.args->list.size());
auto argcount = std::format("{}", exp.args->list.size());
if (type == call::type::local)
{
@ -1605,12 +1605,12 @@ auto compiler::emit_expr_parameters(expr_parameters const& exp, scope& scp) -> v
auto data = std::vector<std::string>{};
auto size = (ctx_->props() & props::hash) ? num * 8 : num;
data.push_back(fmt::format("{}", num));
data.push_back(std::format("{}", num));
for (auto const& entry : exp.list)
{
auto index = variable_initialize(*entry, scp);
data.push_back((ctx_->props() & props::hash) ? entry->value : fmt::format("{}", index));
data.push_back((ctx_->props() & props::hash) ? entry->value : std::format("{}", index));
}
emit_opcode(opcode::OP_FormalParams, data);
@ -1626,7 +1626,7 @@ auto compiler::emit_expr_parameters(expr_parameters const& exp, scope& scp) -> v
{
for (auto const& entry : exp.list)
{
emit_opcode(opcode::OP_SafeCreateVariableFieldCached, fmt::format("{}", variable_initialize(*entry, scp)));
emit_opcode(opcode::OP_SafeCreateVariableFieldCached, std::format("{}", variable_initialize(*entry, scp)));
}
emit_opcode(opcode::OP_checkclearparams);
@ -1698,11 +1698,11 @@ auto compiler::emit_expr_tuple(expr_tuple const& exp, scope& scp) -> void
if (index == 0)
emit_opcode(opcode::OP_GetZero);
else
emit_opcode(opcode::OP_GetByte, fmt::format("{}", index));
emit_opcode(opcode::OP_GetByte, std::format("{}", index));
index++;
emit_opcode(opcode::OP_EvalLocalArrayCached, fmt::format("{}", variable_access(exp.temp->as<expr_identifier>(), scp)));
emit_opcode(opcode::OP_EvalLocalArrayCached, std::format("{}", variable_access(exp.temp->as<expr_identifier>(), scp)));
emit_expr_variable_ref(*entry, scp, true);
}
@ -1750,7 +1750,7 @@ auto compiler::emit_expr_array_ref(expr_array const& exp, scope& scp, bool set)
if (!variable_initialized(exp.obj->as<expr_identifier>(), scp))
{
auto index = variable_initialize(exp.obj->as<expr_identifier>(), scp);
emit_opcode(opcode::OP_EvalNewLocalArrayRefCached0, (ctx_->props() & props::hash) ? exp.obj->as<expr_identifier>().value : fmt::format("{}", index));
emit_opcode(opcode::OP_EvalNewLocalArrayRefCached0, (ctx_->props() & props::hash) ? exp.obj->as<expr_identifier>().value : std::format("{}", index));
if (!set) throw comp_error(exp.loc(), "INTERNAL: VAR CREATED BUT NOT SET");
}
@ -1761,7 +1761,7 @@ auto compiler::emit_expr_array_ref(expr_array const& exp, scope& scp, bool set)
if (index == 0)
emit_opcode(opcode::OP_EvalLocalArrayRefCached0);
else
emit_opcode(opcode::OP_EvalLocalArrayRefCached, fmt::format("{}", index));
emit_opcode(opcode::OP_EvalLocalArrayRefCached, std::format("{}", index));
}
if (set) emit_opcode(opcode::OP_SetVariableField);
@ -1802,7 +1802,7 @@ auto compiler::emit_expr_field_ref(expr_field const& exp, scope& scp, bool set)
if (set) emit_opcode(opcode::OP_SetVariableField);
break;
case node::expr_identifier:
emit_opcode(opcode::OP_EvalLocalVariableObjectCached, fmt::format("{}", variable_access(exp.obj->as<expr_identifier>(), scp)));
emit_opcode(opcode::OP_EvalLocalVariableObjectCached, std::format("{}", variable_access(exp.obj->as<expr_identifier>(), scp)));
emit_opcode(opcode::OP_EvalFieldVariableRef, field);
if (set) emit_opcode(opcode::OP_SetVariableField);
break;
@ -1829,7 +1829,7 @@ auto compiler::emit_expr_local_ref(expr_identifier const& exp, scope& scp, bool
if (it != constants_.end())
{
throw comp_error(exp.loc(), fmt::format("variable name already defined as constant '{}'", exp.value));
throw comp_error(exp.loc(), std::format("variable name already defined as constant '{}'", exp.value));
}
if (set)
@ -1837,7 +1837,7 @@ auto compiler::emit_expr_local_ref(expr_identifier const& exp, scope& scp, bool
if (!variable_initialized(exp, scp))
{
auto index = variable_initialize(exp, scp);
emit_opcode(opcode::OP_SetNewLocalVariableFieldCached0, (ctx_->props() & props::hash) ? exp.value : fmt::format("{}", index));
emit_opcode(opcode::OP_SetNewLocalVariableFieldCached0, (ctx_->props() & props::hash) ? exp.value : std::format("{}", index));
}
else
{
@ -1846,7 +1846,7 @@ auto compiler::emit_expr_local_ref(expr_identifier const& exp, scope& scp, bool
if (index == 0)
emit_opcode(opcode::OP_SetLocalVariableFieldCached0);
else
emit_opcode(opcode::OP_SetLocalVariableFieldCached, fmt::format("{}", index));
emit_opcode(opcode::OP_SetLocalVariableFieldCached, std::format("{}", index));
}
}
else
@ -1856,7 +1856,7 @@ auto compiler::emit_expr_local_ref(expr_identifier const& exp, scope& scp, bool
if (index == 0)
emit_opcode(opcode::OP_EvalLocalVariableRefCached0);
else
emit_opcode(opcode::OP_EvalLocalVariableRefCached, fmt::format("{}", index));
emit_opcode(opcode::OP_EvalLocalVariableRefCached, std::format("{}", index));
}
}
@ -1884,7 +1884,7 @@ auto compiler::emit_expr_array(expr_array const& exp, scope& scp) -> void
if (exp.obj->is<expr_identifier>())
{
emit_opcode(opcode::OP_EvalLocalArrayCached, fmt::format("{}", variable_access(exp.obj->as<expr_identifier>(), scp)));
emit_opcode(opcode::OP_EvalLocalArrayCached, std::format("{}", variable_access(exp.obj->as<expr_identifier>(), scp)));
}
else
{
@ -1929,7 +1929,7 @@ auto compiler::emit_expr_field(expr_field const& exp, scope& scp) -> void
emit_opcode(opcode::OP_EvalFieldVariable, field);
break;
case node::expr_identifier:
emit_opcode(opcode::OP_EvalLocalVariableObjectCached, fmt::format("{}", variable_access(exp.obj->as<expr_identifier>(), scp)));
emit_opcode(opcode::OP_EvalLocalVariableObjectCached, std::format("{}", variable_access(exp.obj->as<expr_identifier>(), scp)));
emit_opcode(opcode::OP_EvalFieldVariable, field);
break;
default:
@ -1971,7 +1971,7 @@ auto compiler::emit_expr_local(expr_identifier const& exp, scope& scp) -> void
emit_opcode(opcode::OP_EvalLocalVariableCached5);
break;
default:
emit_opcode(opcode::OP_EvalLocalVariableCached, fmt::format("{}", index));
emit_opcode(opcode::OP_EvalLocalVariableCached, std::format("{}", index));
break;
}
}
@ -2006,7 +2006,7 @@ auto compiler::emit_expr_object(expr const& exp, scope& scp) -> void
emit_opcode(opcode::OP_CastFieldObject);
break;
case node::expr_identifier:
emit_opcode(opcode::OP_EvalLocalVariableObjectCached, fmt::format("{}", variable_access(exp.as<expr_identifier>(), scp)));
emit_opcode(opcode::OP_EvalLocalVariableObjectCached, std::format("{}", variable_access(exp.as<expr_identifier>(), scp)));
break;
default:
throw comp_error(exp.loc(), "not an object");
@ -2173,7 +2173,7 @@ auto compiler::emit_create_local_vars(scope& scp) -> void
{
for (auto i = scp.create_count; i < scp.public_count; i++)
{
emit_opcode(opcode::OP_CreateLocalVariable, (ctx_->props() & props::hash) ? scp.vars[i].name : fmt::format("{}", scp.vars[i].create));
emit_opcode(opcode::OP_CreateLocalVariable, (ctx_->props() & props::hash) ? scp.vars[i].name : std::format("{}", scp.vars[i].create));
scp.vars[i].init = true;
}
@ -2189,7 +2189,7 @@ auto compiler::emit_remove_local_vars(scope& scp) -> void
if (count > 0)
{
emit_opcode(opcode::OP_RemoveLocalVariables, fmt::format("{}", count));
emit_opcode(opcode::OP_RemoveLocalVariables, std::format("{}", count));
}
}
}
@ -2726,7 +2726,7 @@ auto compiler::variable_initialized(expr_identifier const& exp, scope& scp) -> b
}
}
throw comp_error(exp.loc(), fmt::format("local variable '{}' not found", exp.value));
throw comp_error(exp.loc(), std::format("local variable '{}' not found", exp.value));
}
auto compiler::variable_initialize(expr_identifier const& exp, scope& scp) -> u8
@ -2742,7 +2742,7 @@ auto compiler::variable_initialize(expr_identifier const& exp, scope& scp) -> u8
if (!scp.vars[j].init)
{
scp.vars[j].init = true;
emit_opcode(opcode::OP_CreateLocalVariable, (ctx_->props() & props::hash) ? scp.vars[j].name : fmt::format("{}", scp.vars[j].create));
emit_opcode(opcode::OP_CreateLocalVariable, (ctx_->props() & props::hash) ? scp.vars[j].name : std::format("{}", scp.vars[j].create));
}
}
@ -2753,7 +2753,7 @@ auto compiler::variable_initialize(expr_identifier const& exp, scope& scp) -> u8
}
}
throw comp_error(exp.loc(), fmt::format("local variable '{}' not found", exp.value));
throw comp_error(exp.loc(), std::format("local variable '{}' not found", exp.value));
}
auto compiler::variable_create(expr_identifier const& exp, scope& scp) -> u8
@ -2766,7 +2766,7 @@ auto compiler::variable_create(expr_identifier const& exp, scope& scp) -> u8
{
if (!var.init)
{
emit_opcode(opcode::OP_CreateLocalVariable, (ctx_->props() & props::hash) ? var.name : fmt::format("{}", var.create));
emit_opcode(opcode::OP_CreateLocalVariable, (ctx_->props() & props::hash) ? var.name : std::format("{}", var.create));
var.init = true;
scp.create_count++;
}
@ -2775,7 +2775,7 @@ auto compiler::variable_create(expr_identifier const& exp, scope& scp) -> u8
}
}
throw comp_error(exp.loc(), fmt::format("local variable '{}' not found", exp.value));
throw comp_error(exp.loc(), std::format("local variable '{}' not found", exp.value));
}
auto compiler::variable_access(expr_identifier const& exp, scope& scp) -> u8
@ -2789,11 +2789,11 @@ auto compiler::variable_access(expr_identifier const& exp, scope& scp) -> u8
return static_cast<u8>(scp.create_count - 1 - i);
}
throw comp_error(exp.loc(), fmt::format("local variable '{}' not initialized", exp.value));
throw comp_error(exp.loc(), std::format("local variable '{}' not initialized", exp.value));
}
}
throw comp_error(exp.loc(), fmt::format("local variable '{}' not found", exp.value));
throw comp_error(exp.loc(), std::format("local variable '{}' not found", exp.value));
}
auto compiler::resolve_function_type(expr_function const& exp, std::string& path) -> call::type
@ -2922,7 +2922,7 @@ auto compiler::insert_label() -> std::string
else
{
label_idx_++;
auto name = fmt::format("loc_{}", label_idx_);
auto name = std::format("loc_{}", label_idx_);
function_->labels.insert({ index_, name });
return name;
}
@ -2931,7 +2931,7 @@ auto compiler::insert_label() -> std::string
auto compiler::create_label() -> std::string
{
label_idx_++;
return fmt::format("loc_{}", label_idx_);
return std::format("loc_{}", label_idx_);
}
} // namespace xsk::gsc

View File

@ -279,7 +279,7 @@ auto context::opcode_size(opcode op) const -> u32
case opcode::OP_iw9_144:
case opcode::OP_iw9_166:
default:
throw error(fmt::format("couldn't resolve instruction size for '{}'", opcode_name(op)));
throw error(std::format("couldn't resolve instruction size for '{}'", opcode_name(op)));
}
}
@ -292,7 +292,7 @@ auto context::opcode_id(opcode op) const -> u8
return itr->second;
}
throw error(fmt::format("couldn't resolve opcode id for '{}'", opcode_name(op)));
throw error(std::format("couldn't resolve opcode id for '{}'", opcode_name(op)));
}
auto context::opcode_name(opcode op) const -> std::string
@ -304,7 +304,7 @@ auto context::opcode_name(opcode op) const -> std::string
return std::string{ itr->second };
}
throw std::runtime_error(fmt::format("couldn't resolve opcode string for enum '{}'", static_cast<std::underlying_type_t<opcode>>(op)));
throw std::runtime_error(std::format("couldn't resolve opcode string for enum '{}'", static_cast<std::underlying_type_t<opcode>>(op)));
}
auto context::opcode_enum(std::string const& name) const -> opcode
@ -316,7 +316,7 @@ auto context::opcode_enum(std::string const& name) const -> opcode
return itr->second;
}
throw std::runtime_error(fmt::format("couldn't resolve opcode enum for name '{}'", name));
throw std::runtime_error(std::format("couldn't resolve opcode enum for name '{}'", name));
}
auto context::opcode_enum(u8 id) const -> opcode
@ -328,7 +328,7 @@ auto context::opcode_enum(u8 id) const -> opcode
return itr->second;
}
throw error(fmt::format("couldn't resolve opcode enum for '{:02X}'", id));
throw error(std::format("couldn't resolve opcode enum for '{:02X}'", id));
}
auto context::func_id(std::string const& name) const -> u16
@ -345,7 +345,7 @@ auto context::func_id(std::string const& name) const -> u16
return itr->second;
}
throw error(fmt::format("couldn't resolve builtin function id for {}", name));
throw error(std::format("couldn't resolve builtin function id for {}", name));
}
auto context::func_name(u16 id) const -> std::string
@ -357,7 +357,7 @@ auto context::func_name(u16 id) const -> std::string
return std::string{ itr->second };
}
return fmt::format("_func_{:04X}", id);
return std::format("_func_{:04X}", id);
}
auto context::func2_id(std::string const& name) const -> u64
@ -394,7 +394,7 @@ auto context::func2_name(u64 id) const -> std::string
return std::string{ itr->second };
}
return fmt::format("_func_{:16X}", id);
return std::format("_func_{:16X}", id);
}
auto context::func_exists(std::string const& name) const -> bool
@ -417,7 +417,7 @@ auto context::func_add(std::string const& name, u16 id) -> void
if (itr != func_map_rev_.end())
{
throw error(fmt::format("builtin function '{}' already defined", name));
throw error(std::format("builtin function '{}' already defined", name));
}
auto const str = new_func_map_.find(name);
@ -453,7 +453,7 @@ auto context::meth_id(std::string const& name) const -> u16
return itr->second;
}
throw error(fmt::format("couldn't resolve builtin method id for {}", name));
throw error(std::format("couldn't resolve builtin method id for {}", name));
}
auto context::meth_name(u16 id) const -> std::string
@ -465,7 +465,7 @@ auto context::meth_name(u16 id) const -> std::string
return std::string{ itr->second };
}
return fmt::format("_meth_{:04X}", id);
return std::format("_meth_{:04X}", id);
}
auto context::meth2_id(std::string const& name) const -> u64
@ -502,7 +502,7 @@ auto context::meth2_name(u64 id) const -> std::string
return std::string{ itr->second };
}
return fmt::format("_meth_{:16X}", id);
return std::format("_meth_{:16X}", id);
}
@ -526,7 +526,7 @@ auto context::meth_add(std::string const& name, u16 id) -> void
if (itr != meth_map_rev_.end())
{
throw error(fmt::format("builtin method '{}' already defined", name));
throw error(std::format("builtin method '{}' already defined", name));
}
auto const str = new_meth_map_.find(name);
@ -574,7 +574,7 @@ auto context::token_name(u32 id) const -> std::string
return std::string{ itr->second };
}
return fmt::format("_id_{:04X}", id);
return std::format("_id_{:04X}", id);
}
auto context::path_id(std::string const& name) const -> u64
@ -615,7 +615,7 @@ auto context::path_name(u64 id) const -> std::string
return std::string{ itr->second };
}
return fmt::format("_id_{:016X}", id);
return std::format("_id_{:016X}", id);
}
auto context::hash_id(std::string const& name) const -> u64
@ -652,7 +652,7 @@ auto context::hash_name(u64 id) const -> std::string
return std::string{ itr->second };
}
return fmt::format("_id_{:016X}", id);
return std::format("_id_{:016X}", id);
}
auto context::make_token(std::string_view str) const -> std::string
@ -694,7 +694,7 @@ auto context::load_header(std::string const& name) -> std::tuple<std::string con
}
}
throw error(fmt::format("couldn't open gsh file '{}'", name));
throw error(std::format("couldn't open gsh file '{}'", name));
}
auto context::load_include(std::string const& name) -> bool
@ -755,7 +755,7 @@ auto context::load_include(std::string const& name) -> bool
}
catch (std::exception const& e)
{
throw error(fmt::format("parsing include file '{}': {}", name, e.what()));
throw error(std::format("parsing include file '{}': {}", name, e.what()));
}
}

View File

@ -1238,7 +1238,7 @@ auto decompiler::decompile_instruction(instruction const& inst) -> void
}
case opcode::OP_SafeCreateVariableFieldCached:
{
auto name = (ctx_->props() & props::hash) ? inst.data[0] : fmt::format("var_{}", inst.data[0]);
auto name = (ctx_->props() & props::hash) ? inst.data[0] : std::format("var_{}", inst.data[0]);
func_->params->list.push_back(expr_identifier::make(loc, name));
break;
}
@ -1456,7 +1456,7 @@ auto decompiler::decompile_instruction(instruction const& inst) -> void
for (auto i = 1; i <= count; i++)
{
auto name = (ctx_->props() & props::hash) ? inst.data[i] : fmt::format("var_{}", inst.data[i]);
auto name = (ctx_->props() & props::hash) ? inst.data[i] : std::format("var_{}", inst.data[i]);
func_->params->list.push_back(expr_identifier::make(loc, name));
}
break;
@ -1481,22 +1481,22 @@ auto decompiler::decompile_instruction(instruction const& inst) -> void
}
case opcode::OP_GetStatHash:
{
stack_.push(expr_string::make(loc, fmt::format("stat_{}", inst.data[0])));
stack_.push(expr_string::make(loc, std::format("stat_{}", inst.data[0])));
break;
}
case opcode::OP_GetUnkxHash:
{
stack_.push(expr_string::make(loc, fmt::format("hunk_{}", inst.data[0])));
stack_.push(expr_string::make(loc, std::format("hunk_{}", inst.data[0])));
break;
}
case opcode::OP_GetEnumHash:
{
stack_.push(expr_string::make(loc, fmt::format("enum_{}", inst.data[0])));
stack_.push(expr_string::make(loc, std::format("enum_{}", inst.data[0])));
break;
}
case opcode::OP_GetDvarHash:
{
stack_.push(expr_string::make(loc, fmt::format("dvar_{}", inst.data[0])));
stack_.push(expr_string::make(loc, std::format("dvar_{}", inst.data[0])));
break;
}
case opcode::OP_waittillmatch2:
@ -1505,7 +1505,7 @@ auto decompiler::decompile_instruction(instruction const& inst) -> void
case opcode::OP_CastBool:
break;
default:
throw decomp_error(fmt::format("unhandled opcode {}", ctx_->opcode_name(inst.opcode)));
throw decomp_error(std::format("unhandled opcode {}", ctx_->opcode_name(inst.opcode)));
}
}
@ -1782,7 +1782,7 @@ auto decompiler::decompile_aborts(stmt_list& stm) -> void
}
else
{
std::cout << fmt::format("WARNING: unresolved jump to '{}', maybe incomplete for loop\n", jmp);
std::cout << std::format("WARNING: unresolved jump to '{}', maybe incomplete for loop\n", jmp);
}
}
}
@ -2396,7 +2396,7 @@ auto decompiler::find_location_index(stmt_list const& stm, std::string const& lo
index++;
}
throw decomp_error(fmt::format("location '{}' not found", loc));
throw decomp_error(std::format("location '{}' not found", loc));
}
auto decompiler::last_location_index(stmt_list const& stm, usize index) -> bool
@ -2817,7 +2817,7 @@ auto decompiler::process_stmt_return(stmt_return& stm, scope& scp) -> void
auto decompiler::process_stmt_create(stmt_create& stm, scope& scp) -> void
{
auto var = (ctx_->props() & props::hash) ? stm.index : fmt::format("var_{}", stm.index);
auto var = (ctx_->props() & props::hash) ? stm.index : std::format("var_{}", stm.index);
scp.vars.push_back({ var, static_cast<u8>(scp.create_count), true });
scp.create_count++;
}
@ -3103,12 +3103,12 @@ auto decompiler::process_expr_var_create(expr::ptr& exp, scope& scp) -> void
{
for (auto const& entry : exp->as<expr_var_create>().vars)
{
auto var = (ctx_->props() & props::hash) ? entry : fmt::format("var_{}", entry);
auto var = (ctx_->props() & props::hash) ? entry : std::format("var_{}", entry);
scp.vars.push_back({ var, static_cast<u8>(scp.create_count), true });
scp.create_count++;
}
auto var = (ctx_->props() & props::hash) ? exp->as<expr_var_create>().index : fmt::format("var_{}", exp->as<expr_var_create>().index);
auto var = (ctx_->props() & props::hash) ? exp->as<expr_var_create>().index : std::format("var_{}", exp->as<expr_var_create>().index);
scp.vars.push_back({ var, static_cast<u8>(scp.create_count), true });
scp.create_count++;
@ -3121,7 +3121,7 @@ auto decompiler::process_expr_var_access(expr::ptr& exp, scope& scp) -> void
if (scp.vars.size() <= index)
{
std::cout << fmt::format("WARNING: bad local var access\n");
std::cout << std::format("WARNING: bad local var access\n");
}
else
{

View File

@ -153,21 +153,21 @@ auto disassembler::dissasemble_instruction(instruction& inst) -> void
break;
case opcode::OP_GetByte:
case opcode::OP_GetNegByte:
inst.data.push_back(fmt::format("{}", script_.read<u8>()));
inst.data.push_back(std::format("{}", script_.read<u8>()));
break;
case opcode::OP_GetUnsignedShort:
case opcode::OP_GetNegUnsignedShort:
inst.data.push_back(fmt::format("{}", script_.read<u16>()));
inst.data.push_back(std::format("{}", script_.read<u16>()));
break;
case opcode::OP_GetUnsignedInt:
case opcode::OP_GetNegUnsignedInt:
inst.data.push_back(fmt::format("{}", script_.read<u32>()));
inst.data.push_back(std::format("{}", script_.read<u32>()));
break;
case opcode::OP_GetInteger:
inst.data.push_back(fmt::format("{}", script_.read<i32>()));
inst.data.push_back(std::format("{}", script_.read<i32>()));
break;
case opcode::OP_GetInteger64:
inst.data.push_back(fmt::format("{}", script_.read<i64>()));
inst.data.push_back(std::format("{}", script_.read<i64>()));
break;
case opcode::OP_GetFloat:
inst.data.push_back(utils::string::float_string(script_.read<f32>()));
@ -193,15 +193,15 @@ auto disassembler::dissasemble_instruction(instruction& inst) -> void
inst.data.push_back(decrypt_string(stack_.read_cstr()));
break;
case opcode::OP_GetUnkxHash: // xhash : only used on unittests
inst.data.push_back(fmt::format("{:08X}", script_.read<u32>()));
inst.data.push_back(std::format("{:08X}", script_.read<u32>()));
break;
case opcode::OP_GetStatHash: // xhash : "kill" -> 0xEF9582D72160F199
case opcode::OP_GetEnumHash: // xhash : "WEAPON/AMMO_SLUGS" -> 0x6AA606A18241AD16 c++ enum ??
case opcode::OP_GetDvarHash: // xhash : #d"mapname" -> 0x687FB8F9B7A23245
inst.data.push_back(fmt::format("{:016X}", script_.read<u64>()));
inst.data.push_back(std::format("{:016X}", script_.read<u64>()));
break;
case opcode::OP_waittillmatch:
inst.data.push_back(fmt::format("{}", script_.read<u8>()));
inst.data.push_back(std::format("{}", script_.read<u8>()));
break;
case opcode::OP_ClearLocalVariableFieldCached:
case opcode::OP_SetLocalVariableFieldCached:
@ -213,13 +213,13 @@ auto disassembler::dissasemble_instruction(instruction& inst) -> void
case opcode::OP_SafeSetWaittillVariableFieldCached:
case opcode::OP_EvalLocalVariableObjectCached:
case opcode::OP_EvalLocalArrayCached:
inst.data.push_back(fmt::format("{}", script_.read<u8>()));
inst.data.push_back(std::format("{}", script_.read<u8>()));
break;
case opcode::OP_CreateLocalVariable:
case opcode::OP_EvalNewLocalArrayRefCached0:
case opcode::OP_SafeCreateVariableFieldCached:
case opcode::OP_SetNewLocalVariableFieldCached0:
inst.data.push_back((ctx_->props() & props::hash) ? ctx_->hash_name(script_.read<u64>()) : fmt::format("{}", script_.read<u8>()));
inst.data.push_back((ctx_->props() & props::hash) ? ctx_->hash_name(script_.read<u64>()) : std::format("{}", script_.read<u8>()));
break;
case opcode::OP_EvalSelfFieldVariable:
case opcode::OP_SetLevelFieldVariableField:
@ -241,7 +241,7 @@ auto disassembler::dissasemble_instruction(instruction& inst) -> void
case opcode::OP_ScriptChildThreadCallPointer:
case opcode::OP_ScriptMethodThreadCallPointer:
case opcode::OP_ScriptMethodChildThreadCallPointer:
inst.data.push_back(fmt::format("{}", script_.read<u8>()));
inst.data.push_back(std::format("{}", script_.read<u8>()));
break;
case opcode::OP_GetLocalFunction:
case opcode::OP_ScriptLocalFunctionCall2:
@ -313,7 +313,7 @@ auto disassembler::dissasemble_instruction(instruction& inst) -> void
disassemble_formal_params(inst);
break;
default:
throw disasm_error(fmt::format("unhandled opcode {} at index {:04X}", ctx_->opcode_name(inst.opcode), inst.index));
throw disasm_error(std::format("unhandled opcode {} at index {:04X}", ctx_->opcode_name(inst.opcode), inst.index));
}
}
@ -321,7 +321,7 @@ auto disassembler::disassemble_builtin_call(instruction& inst, bool method, bool
{
if (args)
{
inst.data.push_back(fmt::format("{}", script_.read<u8>()));
inst.data.push_back(std::format("{}", script_.read<u8>()));
}
if (ctx_->props() & props::hash)
@ -350,11 +350,11 @@ auto disassembler::disassemble_local_call(instruction& inst, bool thread) -> voi
{
auto const offs = disassemble_offset();
inst.data.push_back(fmt::format("{}", inst.index + 1 + offs));
inst.data.push_back(std::format("{}", inst.index + 1 + offs));
if (thread)
{
inst.data.push_back(fmt::format("{}", script_.read<u8>()));
inst.data.push_back(std::format("{}", script_.read<u8>()));
}
}
@ -366,7 +366,7 @@ auto disassembler::disassemble_far_call(instruction& inst, bool thread) -> void
if (thread)
{
inst.data.push_back(fmt::format("{}", script_.read<u8>()));
inst.data.push_back(std::format("{}", script_.read<u8>()));
}
auto file = stack_.read<u64>();
@ -374,7 +374,7 @@ auto disassembler::disassemble_far_call(instruction& inst, bool thread) -> void
if (file == 0)
{
inst.data.emplace(inst.data.begin(), fmt::format("{}", inst.index + 1 + offs));
inst.data.emplace(inst.data.begin(), std::format("{}", inst.index + 1 + offs));
inst.data.emplace(inst.data.begin(), "");
}
else
@ -396,7 +396,7 @@ auto disassembler::disassemble_far_call(instruction& inst, bool thread) -> void
if (thread)
{
inst.data.push_back(fmt::format("{}", script_.read<u8>()));
inst.data.push_back(std::format("{}", script_.read<u8>()));
}
auto const file_id = (ctx_->props() & props::tok4) ? stack_.read<u32>() : stack_.read<u16>();
@ -412,7 +412,7 @@ auto disassembler::disassemble_far_call(instruction& inst, bool thread) -> void
auto disassembler::disassemble_switch(instruction& inst) -> void
{
auto const addr = inst.index + 4 + script_.read<i32>();
auto const label = fmt::format("loc_{:X}", addr);
auto const label = std::format("loc_{:X}", addr);
inst.data.push_back(label);
func_->labels.insert({ addr, label });
@ -422,7 +422,7 @@ auto disassembler::disassemble_end_switch(instruction& inst) -> void
{
auto const count = script_.read<u16>();
inst.data.push_back(fmt::format("{}", count));
inst.data.push_back(std::format("{}", count));
auto type = switch_type::none;
auto index = inst.index + 3u;
@ -439,13 +439,13 @@ auto disassembler::disassemble_end_switch(instruction& inst) -> void
if (byte == 1)
{
inst.data.push_back("case");
inst.data.push_back(fmt::format("{}", static_cast<std::underlying_type_t<switch_type>>(switch_type::integer)));
inst.data.push_back(fmt::format("{}", data));
inst.data.push_back(std::format("{}", static_cast<std::underlying_type_t<switch_type>>(switch_type::integer)));
inst.data.push_back(std::format("{}", data));
}
else if (byte == 2)
{
inst.data.push_back("case");
inst.data.push_back(fmt::format("{}", static_cast<std::underlying_type_t<switch_type>>(switch_type::string)));
inst.data.push_back(std::format("{}", static_cast<std::underlying_type_t<switch_type>>(switch_type::string)));
inst.data.push_back(stack_.read_cstr());
}
else // byte == 0
@ -455,7 +455,7 @@ auto disassembler::disassemble_end_switch(instruction& inst) -> void
}
auto const addr = index + 4 + offs;
auto const label = fmt::format("loc_{:X}", addr);
auto const label = std::format("loc_{:X}", addr);
inst.data.push_back(label);
func_->labels.insert({ addr, label });
@ -488,11 +488,11 @@ auto disassembler::disassemble_end_switch(instruction& inst) -> void
type = switch_type::integer;
inst.data.push_back("case");
inst.data.push_back(fmt::format("{}", (value - 0x800000) & 0xFFFFFF));
inst.data.push_back(std::format("{}", (value - 0x800000) & 0xFFFFFF));
}
auto const addr = index + 4 + disassemble_offset();
auto const label = fmt::format("loc_{:X}", addr);
auto const label = std::format("loc_{:X}", addr);
inst.data.push_back(label);
func_->labels.insert({ addr, label });
@ -502,7 +502,7 @@ auto disassembler::disassemble_end_switch(instruction& inst) -> void
}
}
inst.data.push_back(fmt::format("{}", static_cast<std::underlying_type_t<switch_type>>(type)));
inst.data.push_back(std::format("{}", static_cast<std::underlying_type_t<switch_type>>(type)));
}
auto disassembler::disassemble_field_variable(instruction& inst) -> void
@ -519,7 +519,7 @@ auto disassembler::disassemble_field_variable(instruction& inst) -> void
if (id > ctx_->str_count())
{
auto const temp = (ctx_->props() & props::tok4) ? stack_.read<u32>() : stack_.read<u16>();
name = (temp == 0) ? decrypt_string(stack_.read_cstr()) : fmt::format("{}", temp);
name = (temp == 0) ? decrypt_string(stack_.read_cstr()) : std::format("{}", temp);
}
else
{
@ -535,11 +535,11 @@ auto disassembler::disassemble_formal_params(instruction& inst) -> void
auto const count = script_.read<u8>();
inst.size += (ctx_->props() & props::hash) ? count * 8 : count;
inst.data.push_back(fmt::format("{}", count));
inst.data.push_back(std::format("{}", count));
for (auto i = 0u; i < count; i++)
{
inst.data.push_back((ctx_->props() & props::hash) ? ctx_->hash_name(script_.read<u64>()) : fmt::format("{}", script_.read<u8>()));
inst.data.push_back((ctx_->props() & props::hash) ? ctx_->hash_name(script_.read<u64>()) : std::format("{}", script_.read<u8>()));
}
}
@ -560,7 +560,7 @@ auto disassembler::disassemble_jump(instruction& inst, bool expr, bool back) ->
addr = inst.index + 5 + script_.read<i32>();
}
auto const label = fmt::format("loc_{:X}", addr);
auto const label = std::format("loc_{:X}", addr);
inst.data.push_back(label);
func_->labels.insert({ addr, label });
@ -639,7 +639,7 @@ auto disassembler::resolve_function(std::string const& index) -> std::string
}
}
throw disasm_error(fmt::format("couldn't resolve function name at index 0x{}", index));
throw disasm_error(std::format("couldn't resolve function name at index 0x{}", index));
}
auto disassembler::decrypt_string(std::string const& str) -> std::string
@ -652,7 +652,7 @@ auto disassembler::decrypt_string(std::string const& str) -> std::string
for (auto i = 0u; i < str.size(); i++)
{
data += fmt::format("{:02X}", static_cast<u8>(str[i]));
data += std::format("{:02X}", static_cast<u8>(str[i]));
}
return data;

View File

@ -327,7 +327,7 @@ auto lexer::lex() -> token
else if (last == '_' || (last >= 'A' && last <= 'Z') || (last >= 'a' && last <= 'z'))
goto lex_name;
throw comp_error(loc_, fmt::format("bad token: '{}'", last));
throw comp_error(loc_, std::format("bad token: '{}'", last));
}
lex_string:

View File

@ -1642,7 +1642,7 @@ namespace xsk { namespace gsc {
int yylen = 0;
// Error handling.
int yynerrs_ = 0;
[[maybe_unused]] int yynerrs_ = 0;
int yyerrstatus_ = 0;
/// The lookahead symbol.
@ -2229,7 +2229,7 @@ namespace xsk { namespace gsc {
#line 322 "parser.ypp"
{
ppr.ban_header(yylhs.location); yylhs.value.as < decl_constant::ptr > () = decl_constant::make(yylhs.location, std::move(yystack_[3].value.as < expr_identifier::ptr > ()), std::move(yystack_[1].value.as < expr::ptr > ()));
printf("%s" , fmt::format("{}: constants deprecated, use #define instead\n", yylhs.location.print()).data());
printf("%s" , std::format("{}: constants deprecated, use #define instead\n", yylhs.location.print()).data());
}
#line 2242 "parser.cpp"
break;
@ -2645,8 +2645,8 @@ namespace xsk { namespace gsc {
case 89: // stmt_foreach: "foreach" "(" expr_identifier "in" expr ")" stmt
#line 498 "parser.ypp"
{
auto array = expr_identifier::make(yylhs.location, fmt::format("_temp_{}", ++index));
auto key = expr_identifier::make(yylhs.location, fmt::format("_temp_{}", ++index));
auto array = expr_identifier::make(yylhs.location, std::format("_temp_{}", ++index));
auto key = expr_identifier::make(yylhs.location, std::format("_temp_{}", ++index));
yylhs.value.as < stmt_foreach::ptr > () = stmt_foreach::make(yylhs.location, std::move(yystack_[2].value.as < expr::ptr > ()), std::move(yystack_[4].value.as < expr_identifier::ptr > ()), expr_empty::make(yylhs.location), std::move(array), std::move(key), std::move(yystack_[0].value.as < stmt::ptr > ()), false);
}
#line 2660 "parser.cpp"
@ -2655,8 +2655,8 @@ namespace xsk { namespace gsc {
case 90: // stmt_foreach: "foreach" "(" expr_identifier "," expr_identifier "in" expr ")" stmt
#line 504 "parser.ypp"
{
auto array = expr_identifier::make(yylhs.location, fmt::format("_temp_{}", ++index));
expr::ptr key = (ctx_->props() & props::foreach) ? expr_identifier::make(yylhs.location, fmt::format("_temp_{}", ++index)) : std::move(yystack_[6].value.as < expr_identifier::ptr > ());
auto array = expr_identifier::make(yylhs.location, std::format("_temp_{}", ++index));
expr::ptr key = (ctx_->props() & props::foreach) ? expr_identifier::make(yylhs.location, std::format("_temp_{}", ++index)) : std::move(yystack_[6].value.as < expr_identifier::ptr > ());
yylhs.value.as < stmt_foreach::ptr > () = stmt_foreach::make(yylhs.location, std::move(yystack_[2].value.as < expr::ptr > ()), std::move(yystack_[4].value.as < expr_identifier::ptr > ()), (ctx_->props() & props::foreach) ? std::move(yystack_[6].value.as < expr_identifier::ptr > ()) : (expr::ptr)expr_empty::make(yylhs.location), std::move(array), std::move(key), std::move(yystack_[0].value.as < stmt::ptr > ()), true);
}
#line 2670 "parser.cpp"
@ -3374,7 +3374,7 @@ namespace xsk { namespace gsc {
#line 822 "parser.ypp"
{
yylhs.value.as < expr::ptr > () = std::move(yystack_[1].value.as < expr_tuple::ptr > ());
yylhs.value.as < expr::ptr > ()->as<expr_tuple>().temp = expr_identifier::make(yylhs.value.as < expr::ptr > ()->loc(), fmt::format("_temp_{}", ++index));
yylhs.value.as < expr::ptr > ()->as<expr_tuple>().temp = expr_identifier::make(yylhs.value.as < expr::ptr > ()->loc(), std::format("_temp_{}", ++index));
}
#line 3387 "parser.cpp"
break;
@ -5048,7 +5048,7 @@ auto map_token(context const* ctx_, token& tok) -> parser::symbol_type
}
}
throw error(fmt::format("unmapped token! {}", (u8)tok.type));
throw error(std::format("unmapped token! {}", (u8)tok.type));
}
auto GSClex(context const* ctx_, preprocessor& ppr) -> parser::symbol_type

View File

@ -97,12 +97,12 @@ auto preprocessor::push_header(std::string const& file) -> void
{
try
{
auto name = fmt::format("{}.gsh", file);
auto name = std::format("{}.gsh", file);
for (auto& inc : includes_)
{
if (inc == name)
throw ppr_error(location{}, fmt::format("recursive header inclusion {} at {}", name, includes_.back()));
throw ppr_error(location{}, std::format("recursive header inclusion {} at {}", name, includes_.back()));
}
auto data = ctx_->load_header(name);
@ -112,7 +112,7 @@ auto preprocessor::push_header(std::string const& file) -> void
}
catch (std::exception const& e)
{
throw error(fmt::format("parsing header file '{}': {}", file, e.what()));
throw error(std::format("parsing header file '{}': {}", file, e.what()));
}
}
@ -252,7 +252,7 @@ auto preprocessor::read_directive(token& tok) -> void
}
}
throw ppr_error(next.pos, fmt::format("invalid preprocessing directive '{}'", next.data));
throw ppr_error(next.pos, std::format("invalid preprocessing directive '{}'", next.data));
}
auto preprocessor::read_directive_if(token&) -> void
@ -746,7 +746,7 @@ auto preprocessor::expand(token& tok, define& def) -> void
}
else if (tok.data == "__LINE__")
{
tokens_.push_front(token{ token::STRING, tok.space, tok.pos, fmt::format("{}", tok.pos.begin.line) });
tokens_.push_front(token{ token::STRING, tok.space, tok.pos, std::format("{}", tok.pos.begin.line) });
}
else if (tok.data == "__DATE__")
{
@ -925,7 +925,7 @@ auto preprocessor::expect(token& tok, token::kind expected, spacing) -> void
{
if (tok.type != expected)
{
throw ppr_error(tok.pos, fmt::format("expected {} found {}", (u8)expected, (u8)tok.type));
throw ppr_error(tok.pos, std::format("expected {} found {}", (u8)expected, (u8)tok.type));
}
}
@ -1078,7 +1078,7 @@ auto preprocessor::eval_consume(token::kind type, std::string_view msg)
{
if (eval_check(type)) return eval_next();
throw ppr_error(eval_peek().pos, fmt::format("{}", msg));
throw ppr_error(eval_peek().pos, std::format("{}", msg));
}
auto preprocessor::eval_expr() -> i32

File diff suppressed because it is too large Load Diff

View File

@ -179,7 +179,7 @@ auto assemble_file(game game, mach mach, fs::path file, fs::path rel) -> result
auto path = fs::path{ "assembled" } / rel;
utils::file::save(path, std::get<0>(outbin).data, std::get<0>(outbin).size);
utils::file::save(path.replace_extension(".cgsc.stack"), std::get<1>(outbin).data, std::get<1>(outbin).size);
std::cout << fmt::format("assembled {}\n", rel.generic_string());
std::cout << std::format("assembled {}\n", rel.generic_string());
}
else
{
@ -199,7 +199,7 @@ auto assemble_file(game game, mach mach, fs::path file, fs::path rel) -> result
auto result = script.serialize();
utils::file::save(fs::path{ "assembled" } / rel, result);
std::cout << fmt::format("assembled {}\n", rel.generic_string());
std::cout << std::format("assembled {}\n", rel.generic_string());
}
}
@ -207,7 +207,7 @@ auto assemble_file(game game, mach mach, fs::path file, fs::path rel) -> result
}
catch (std::exception const& e)
{
std::cerr << fmt::format("{} at {}\n", e.what(), file.generic_string());
std::cerr << std::format("{} at {}\n", e.what(), file.generic_string());
return result::failure;
}
}
@ -247,12 +247,12 @@ auto disassemble_file(game game, mach mach, fs::path file, fs::path rel) -> resu
auto outsrc = contexts[game][mach]->source().dump(*outasm);
utils::file::save(fs::path{ "disassembled" } / rel, outsrc);
std::cout << fmt::format("disassembled {}\n", rel.generic_string());
std::cout << std::format("disassembled {}\n", rel.generic_string());
return result::success;
}
catch (std::exception const& e)
{
std::cerr << fmt::format("{} at {}\n", e.what(), file.generic_string());
std::cerr << std::format("{} at {}\n", e.what(), file.generic_string());
return result::failure;
}
}
@ -274,7 +274,7 @@ auto compile_file(game game, mach mach, fs::path file, fs::path rel) -> result
auto path = fs::path{ "compiled" } / rel;
utils::file::save(path, std::get<0>(outbin).data, std::get<0>(outbin).size);
utils::file::save(path.replace_extension(".cgsc.stack"), std::get<1>(outbin).data, std::get<1>(outbin).size);
std::cout << fmt::format("compiled {}\n", rel.generic_string());
std::cout << std::format("compiled {}\n", rel.generic_string());
}
else
{
@ -294,12 +294,12 @@ auto compile_file(game game, mach mach, fs::path file, fs::path rel) -> result
auto result = script.serialize();
utils::file::save(fs::path{ "compiled" } / rel, result);
std::cout << fmt::format("compiled {}\n", rel.generic_string());
std::cout << std::format("compiled {}\n", rel.generic_string());
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());
std::cout << std::format("saved developer map {}\n", rel.generic_string());
}
}
}
@ -308,7 +308,7 @@ auto compile_file(game game, mach mach, fs::path file, fs::path rel) -> result
}
catch (std::exception const& e)
{
std::cerr << fmt::format("{} at {}\n", e.what(), file.generic_string());
std::cerr << std::format("{} at {}\n", e.what(), file.generic_string());
return result::failure;
}
}
@ -349,12 +349,12 @@ auto decompile_file(game game, mach mach, fs::path file, fs::path rel) -> result
auto outsrc = contexts[game][mach]->source().dump(*outast);
utils::file::save(fs::path{ "decompiled" } / rel, outsrc);
std::cout << fmt::format("decompiled {}\n", rel.generic_string());
std::cout << std::format("decompiled {}\n", rel.generic_string());
return result::success;
}
catch (std::exception const& e)
{
std::cerr << fmt::format("{} at {}\n", e.what(), file.generic_string());
std::cerr << std::format("{} at {}\n", e.what(), file.generic_string());
return result::failure;
}
}
@ -369,12 +369,12 @@ auto parse_file(game game, mach mach, fs::path file, fs::path rel) -> result
auto prog = contexts[game][mach]->source().parse_program(file.string(), data);
utils::file::save(fs::path{ "parsed" } / rel, contexts[game][mach]->source().dump(*prog));
std::cout << fmt::format("parsed {}\n", rel.generic_string());
std::cout << std::format("parsed {}\n", rel.generic_string());
return result::success;
}
catch (std::exception const& e)
{
std::cerr << fmt::format("{} at {}\n", e.what(), file.generic_string());
std::cerr << std::format("{} at {}\n", e.what(), file.generic_string());
return result::failure;
}
}
@ -419,20 +419,20 @@ auto rename_file(game game, mach mach, fs::path file, fs::path rel) -> result
auto data = utils::file::read(file);
utils::file::save(fs::path{ "renamed" } / rel, data);
std::cout << fmt::format("renamed {} -> {}\n", file.filename().generic_string(), rel.generic_string());
std::cout << std::format("renamed {} -> {}\n", file.filename().generic_string(), rel.generic_string());
if (zt)
{
auto stack = utils::file::read(file.replace_extension(".cgsc.stack"));
utils::file::save(fs::path{ "renamed" } / rel.replace_extension(".cgsc.stack"), stack);
std::cout << fmt::format("renamed {} -> {}\n", file.filename().generic_string(), rel.generic_string());
std::cout << std::format("renamed {} -> {}\n", file.filename().generic_string(), rel.generic_string());
}
return result::success;
}
catch (std::exception const& e)
{
std::cerr << fmt::format("{} at {}\n", e.what(), file.generic_string());
std::cerr << std::format("{} at {}\n", e.what(), file.generic_string());
return result::failure;
}
}
@ -749,12 +749,12 @@ auto assemble_file(game game, mach mach, fs::path const& file, fs::path rel) ->
auto outbin = contexts[game][mach]->assembler().assemble(*outasm);
utils::file::save(fs::path{ "assembled" } / rel, outbin.first.data, outbin.first.size);
std::cout << fmt::format("assembled {}\n", rel.generic_string());
std::cout << std::format("assembled {}\n", rel.generic_string());
return result::success;
}
catch (std::exception const& e)
{
std::cerr << fmt::format("{} at {}\n", e.what(), file.generic_string());
std::cerr << std::format("{} at {}\n", e.what(), file.generic_string());
return result::failure;
}
}
@ -770,12 +770,12 @@ auto disassemble_file(game game, mach mach, fs::path const& file, fs::path rel)
auto outsrc = contexts[game][mach]->source().dump(*outasm);
utils::file::save(fs::path{ "disassembled" } / rel, outsrc);
std::cout << fmt::format("disassembled {}\n", rel.generic_string());
std::cout << std::format("disassembled {}\n", rel.generic_string());
return result::success;
}
catch (std::exception const& e)
{
std::cerr << fmt::format("{} at {}\n", e.what(), file.generic_string());
std::cerr << std::format("{} at {}\n", e.what(), file.generic_string());
return result::failure;
}
}
@ -793,7 +793,7 @@ auto compile_file(game game, mach mach, fs::path const& file, fs::path rel) -> r
if (!std::memcmp(&data[0], "\x80GSC", 4))
{
std::cerr << fmt::format("{} at {}\n", "already compiled", file.generic_string());
std::cerr << std::format("{} at {}\n", "already compiled", file.generic_string());
return result::success;
}
@ -801,19 +801,19 @@ auto compile_file(game game, mach mach, fs::path const& file, fs::path rel) -> r
auto outbin = contexts[game][mach]->assembler().assemble(*outasm);
utils::file::save(fs::path{ "compiled" } / rel, outbin.first.data, outbin.first.size);
std::cout << fmt::format("compiled {}\n", rel.generic_string());
std::cout << std::format("compiled {}\n", rel.generic_string());
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());
std::cout << std::format("saved developer map {}\n", rel.generic_string());
}
return result::success;
}
catch (std::exception const& e)
{
std::cerr << fmt::format("{} at {}\n", e.what(), file.generic_string());
std::cerr << std::format("{} at {}\n", e.what(), file.generic_string());
return result::failure;
}
}
@ -831,25 +831,25 @@ auto decompile_file(game game, mach mach, fs::path const& file, fs::path rel) ->
auto output = contexts[game][mach]->source().dump(*outsrc);
utils::file::save(fs::path{ "decompiled" } / rel, output);
std::cout << fmt::format("decompiled {}\n", rel.generic_string());
std::cout << std::format("decompiled {}\n", rel.generic_string());
return result::success;
}
catch (std::exception const& e)
{
std::cerr << fmt::format("{} at {}\n", e.what(), file.generic_string());
std::cerr << std::format("{} at {}\n", e.what(), file.generic_string());
return result::failure;
}
}
auto parse_file(game, mach, fs::path const&, fs::path) -> result
{
std::cerr << fmt::format("not implemented for treyarch\n");
std::cerr << std::format("not implemented for treyarch\n");
return result::failure;
}
auto rename_file(game, mach, fs::path const&, fs::path) -> result
{
std::cerr << fmt::format("not implemented for treyarch\n");
std::cerr << std::format("not implemented for treyarch\n");
return result::failure;
}
@ -1023,7 +1023,7 @@ auto execute(mode mode, game game, mach mach, fs::path const& path, bool dev) ->
{
if (!extension_match(path.extension(), mode, game))
{
std::cerr << fmt::format("bad extension '{}'\n", path.extension().string());
std::cerr << std::format("bad extension '{}'\n", path.extension().string());
return result::failure;
}
@ -1034,7 +1034,7 @@ auto execute(mode mode, game game, mach mach, fs::path const& path, bool dev) ->
}
else
{
std::cerr << fmt::format("bad path '{}'\n", path.generic_string());
std::cerr << std::format("bad path '{}'\n", path.generic_string());
return result::failure;
}
}
@ -1090,7 +1090,7 @@ auto parse_system(std::string const& arg, mach& out) -> bool
auto branding() -> std::string
{
return fmt::format("GSC Tool {} created by xensik\n", XSK_VERSION_STR);
return std::format("GSC Tool {} created by xensik\n", XSK_VERSION_STR);
}
auto main(u32 argc, char** argv) -> result

View File

@ -17,7 +17,7 @@ auto file::read(std::filesystem::path const& file) -> std::vector<u8>
if (!stream.good() && !stream.is_open())
{
throw std::runtime_error(fmt::format("couldn't open file {}", file.string()));
throw std::runtime_error(std::format("couldn't open file {}", file.string()));
}
stream.seekg(0, std::ios::end);

View File

@ -207,7 +207,7 @@ auto reader::read_bytes(u32 pos, u32 count) -> std::string
for (auto i = pos; i < pos + count; i++)
{
fmt::format_to(std::back_insert_iterator(data), "{:02X} ", *reinterpret_cast<u8 const*>(data_ + i));
std::format_to(std::back_insert_iterator(data), "{:02X} ", *reinterpret_cast<u8 const*>(data_ + i));
}
data.pop_back();

View File

@ -25,7 +25,7 @@ auto zlib::compress(std::vector<u8> const& data) -> std::vector<u8>
return output;
}
throw std::runtime_error(fmt::format("zlib compress error {}", result));
throw std::runtime_error(std::format("zlib compress error {}", result));
}
auto zlib::decompress(std::vector<u8> const& data, u32 length) -> std::vector<u8>
@ -38,7 +38,7 @@ auto zlib::decompress(std::vector<u8> const& data, u32 length) -> std::vector<u8
if (result == Z_OK)
return output;
throw std::runtime_error(fmt::format("zlib decompress error {}", result));
throw std::runtime_error(std::format("zlib decompress error {}", result));
}
} // namespace xsk::uitls