mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-28 10:59:16 -04:00
7c40d33db3
Phase 1a (boot slice): 30 instructions at 0xBFC00000, compiles clean. Phase 1b (instruction coverage): 54 opcodes implemented in strict_translator, 44,629 walker-reachable instructions covered, 0 missing. Phase 1c (function discovery): 76 functions from 2 seeds, 2,988 instructions, 199 call edges, 27 indirect jumps. All validated through StrictTranslator. Phase 1d (indirect control flow): 27 sites classified — 21 A0/B0/C0 dispatch stubs, 4 computed calls, 2 computed tail calls. Ghidra cross-referenced with 0 disagreements. Phase 1e (relocation): ROM-to-RAM copy at FUN_bfc00420 proven with both Ghidra (static) and DuckStation (runtime). 69 address aliases, 68/69 function entries match byte-for-byte in RAM. Normalization rule documented. Includes PRINCIPLES.md and DEBUG.md adapted from recomp-template. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
140 lines
4.0 KiB
C++
140 lines
4.0 KiB
C++
#include <toml.hpp>
|
|
|
|
#include <iomanip>
|
|
#include <iostream>
|
|
|
|
struct json_serializer
|
|
{
|
|
void operator()(toml::boolean v)
|
|
{
|
|
std::cout << "{\"type\":\"bool\",\"value\":\"" << toml::value(v) << "\"}";
|
|
return ;
|
|
}
|
|
void operator()(toml::integer v)
|
|
{
|
|
std::cout << "{\"type\":\"integer\",\"value\":\"" << toml::value(v) << "\"}";
|
|
return ;
|
|
}
|
|
void operator()(toml::floating v)
|
|
{
|
|
if(std::isnan(v) && std::signbit(v))
|
|
{
|
|
// toml-test does not allow negative NaN represented in "-nan" because
|
|
// there are languages that does not distinguish nan and -nan.
|
|
// But toml11 keeps sign from input. To resolve this difference,
|
|
// we convert -nan to nan here.
|
|
v = std::numeric_limits<toml::floating>::quiet_NaN();
|
|
}
|
|
std::cout << "{\"type\":\"float\",\"value\":\"" << toml::value(v) << "\"}";
|
|
return ;
|
|
}
|
|
void operator()(const toml::string& v)
|
|
{
|
|
// since toml11 automatically convert string to multiline string that is
|
|
// valid only in TOML, we need to format the string to make it valid in
|
|
// JSON.
|
|
toml::serializer<toml::value> ser(std::numeric_limits<std::size_t>::max());
|
|
std::cout << "{\"type\":\"string\",\"value\":"
|
|
<< ser(v.str) << "}";
|
|
return ;
|
|
}
|
|
void operator()(const toml::local_time& v)
|
|
{
|
|
std::cout << "{\"type\":\"time-local\",\"value\":\"" << toml::value(v) << "\"}";
|
|
return ;
|
|
}
|
|
void operator()(const toml::local_date& v)
|
|
{
|
|
std::cout << "{\"type\":\"date-local\",\"value\":\"" << toml::value(v) << "\"}";
|
|
return ;
|
|
}
|
|
void operator()(const toml::local_datetime& v)
|
|
{
|
|
std::cout << "{\"type\":\"datetime-local\",\"value\":\"" << toml::value(v) << "\"}";
|
|
return ;
|
|
}
|
|
void operator()(const toml::offset_datetime& v)
|
|
{
|
|
std::cout << "{\"type\":\"datetime\",\"value\":\"" << toml::value(v) << "\"}";
|
|
return ;
|
|
}
|
|
void operator()(const toml::array& v)
|
|
{
|
|
if(!v.empty() && v.front().is_table())
|
|
{
|
|
std::cout << '[';
|
|
bool is_first = true;
|
|
for(const auto& elem : v)
|
|
{
|
|
if(!is_first) {std::cout << ", ";}
|
|
is_first = false;
|
|
toml::visit(*this, elem);
|
|
}
|
|
std::cout << ']';
|
|
}
|
|
else
|
|
{
|
|
// std::cout << "{\"type\":\"array\",\"value\":[";
|
|
std::cout << "[";
|
|
bool is_first = true;
|
|
for(const auto& elem : v)
|
|
{
|
|
if(!is_first) {std::cout << ", ";}
|
|
is_first = false;
|
|
toml::visit(*this, elem);
|
|
}
|
|
std::cout << "]";
|
|
}
|
|
return ;
|
|
}
|
|
void operator()(const toml::table& v)
|
|
{
|
|
std::cout << '{';
|
|
bool is_first = true;
|
|
for(const auto& elem : v)
|
|
{
|
|
if(!is_first) {std::cout << ", ";}
|
|
is_first = false;
|
|
const auto k = toml::format_key(elem.first);
|
|
if(k.at(0) == '"')
|
|
{
|
|
std::cout << k << ":";
|
|
}
|
|
else // bare key
|
|
{
|
|
std::cout << '\"' << k << "\":";
|
|
}
|
|
toml::visit(*this, elem.second);
|
|
}
|
|
std::cout << '}';
|
|
return ;
|
|
}
|
|
};
|
|
|
|
int main()
|
|
{
|
|
try
|
|
{
|
|
std::vector<char> buf;
|
|
std::cin.peek();
|
|
while(!std::cin.eof())
|
|
{
|
|
buf.push_back(std::cin.get());
|
|
std::cin.peek();
|
|
}
|
|
std::string bufstr(buf.begin(), buf.end());
|
|
|
|
std::istringstream ss(bufstr);
|
|
|
|
const auto data = toml::parse(ss);
|
|
std::cout << std::setprecision(std::numeric_limits<double>::max_digits10);
|
|
toml::visit(json_serializer(), data);
|
|
return 0;
|
|
}
|
|
catch(const toml::syntax_error& err)
|
|
{
|
|
std::cout << "what(): " << err.what() << std::endl;
|
|
return 1;
|
|
}
|
|
}
|