Skip to content

Commit

Permalink
Decompile primary and secondary command infra
Browse files Browse the repository at this point in the history
  • Loading branch information
grunt-lucas committed Sep 1, 2023
1 parent 407d6b8 commit be5fb62
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ namespace porytiles {

enum class TilesOutputPalette { TRUE_COLOR, GREYSCALE };

enum class Subcommand { DECOMPILE, COMPILE_PRIMARY, COMPILE_SECONDARY };
enum class Subcommand { DECOMPILE_PRIMARY, DECOMPILE_SECONDARY, COMPILE_PRIMARY, COMPILE_SECONDARY };

enum class CompilerMode { PRIMARY, SECONDARY };

Expand Down
20 changes: 15 additions & 5 deletions src/cli_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ void parseOptions(PtContext &ctx, int argc, char *const *argv)
parseSubcommand(ctx, argc, argv);

switch (ctx.subcommand) {
case Subcommand::DECOMPILE:
case Subcommand::DECOMPILE_PRIMARY:
throw std::runtime_error{"TODO : support decompile command"};
break;
case Subcommand::DECOMPILE_SECONDARY:
throw std::runtime_error{"TODO : support decompile command"};
break;
case Subcommand::COMPILE_PRIMARY:
Expand Down Expand Up @@ -177,7 +180,10 @@ HELP_DESC + "\n" +
VERBOSE_DESC + "\n" +
VERSION_DESC + "\n"
"COMMANDS\n"
" decompile\n"
" decompile-primary\n"
" Under construction.\n"
"\n"
" decompile-secondary\n"
" Under construction.\n"
"\n"
" compile-primary\n"
Expand Down Expand Up @@ -240,7 +246,8 @@ static void parseGlobalOptions(PtContext &ctx, int argc, char *const *argv)
// | SUBCOMMAND PARSING |
// ----------------------------

const std::string DECOMPILE_COMMAND = "decompile";
const std::string DECOMPILE_PRIMARY_COMMAND = "decompile-primary";
const std::string DECOMPILE_SECONDARY_COMMAND = "decompile-secondary";
const std::string COMPILE_PRIMARY_COMMAND = "compile-primary";
const std::string COMPILE_SECONDARY_COMMAND = "compile-secondary";
static void parseSubcommand(PtContext &ctx, int argc, char *const *argv)
Expand All @@ -250,8 +257,11 @@ static void parseSubcommand(PtContext &ctx, int argc, char *const *argv)
}

std::string subcommand = argv[optind++];
if (subcommand == DECOMPILE_COMMAND) {
ctx.subcommand = Subcommand::DECOMPILE;
if (subcommand == DECOMPILE_PRIMARY_COMMAND) {
ctx.subcommand = Subcommand::DECOMPILE_PRIMARY;
}
else if (subcommand == DECOMPILE_SECONDARY_COMMAND) {
ctx.subcommand = Subcommand::DECOMPILE_SECONDARY;
}
else if (subcommand == COMPILE_PRIMARY_COMMAND) {
ctx.subcommand = Subcommand::COMPILE_PRIMARY;
Expand Down
3 changes: 2 additions & 1 deletion src/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ static void driveCompile(PtContext &ctx)
void drive(PtContext &ctx)
{
switch (ctx.subcommand) {
case Subcommand::DECOMPILE:
case Subcommand::DECOMPILE_PRIMARY:
case Subcommand::DECOMPILE_SECONDARY:
driveDecompile(ctx);
break;
case Subcommand::COMPILE_PRIMARY:
Expand Down

0 comments on commit be5fb62

Please sign in to comment.