30 std::println(
"Success! Output to {}",
m_args.outputFile.string());
35 std::println(std::cerr,
"Failed to disassemble program!");
42 m_args.program = std::filesystem::path(argv[0]);
43 for (
int i = 1; i < argc; i++)
45 std::string arg = argv[i];
47 if (arg ==
"-h" || arg ==
"--help")
52 else if (arg ==
"-o" || arg ==
"--output")
56 m_args.outputFile = argv[++i];
60 std::println(std::cerr,
"Error: {} requires an argument", arg);
65 if (arg ==
"-s" || arg ==
"--silent")
69 else if (arg[0] ==
'-')
71 std::println(std::cerr,
"Error: Unknown option: {}", arg);
77 if (
m_args.inputFile.empty())
81 std::println(std::cerr,
"Error: Multiple input files specified");
92 std::println(
"Phasor Disassembler v{}\n"
93 "(C) 2026 Daniel McGuire - Licensed under Apache 2.0\n\n"
95 " {} [options] <input.phsb>\n"
97 " -o, --output <file> Output file\n"
98 " -h, --help Show this help message\n"
99 " -s, --silent Do not print anything except errors (no stdout)",
100 PHASOR_VERSION_STRING,
m_args.program.stem().string());
108 if (
m_args.outputFile.empty())
111 std::filesystem::path path(
m_args.outputFile);
112 path.replace_extension(
".phir");
113 m_args.outputFile = path.string();
Bytecode binary format deserializer.
Bytecode loadFromFile(const std::filesystem::path &filename)
Load bytecode from .phsb file.
struct Phasor::Disassembler::Args m_args
bool parseArguments(int argc, char *argv[])
Disassembler(int argc, char *argv[])
Phasor IR Serializer/Deserializer.
static bool saveToFile(const Bytecode &bytecode, const std::filesystem::path &filename)
Save bytecode to .phir file.
The Phasor Programming Language and Runtime.