From d651f891b16ec630813c2f91fd4682de22973162 Mon Sep 17 00:00:00 2001 From: revsic Date: Sat, 6 Apr 2019 01:30:41 +0900 Subject: [PATCH] temporal commit --- obfuscator.hpp | 32 ++++++++++++++++++++++---------- obfuscator/obfs/fsm.hpp | 32 ++++++++++++++++++++++---------- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/obfuscator.hpp b/obfuscator.hpp index b0fd998..932aa90 100644 --- a/obfuscator.hpp +++ b/obfuscator.hpp @@ -136,19 +136,25 @@ namespace obfs { using next = typename Machine::template next; using next_s = typename Machine::template next_s; - constexpr static void run() { - if (next::action()) { - return; + constexpr static auto run() { + if (std::is_same_v || next::action()) { + return Machine{}; } - MachineExecutor::run(); + return MachineExecutor::run(); } }; template struct MachineExecutor { using next = typename Machine::template next; - constexpr static void run() { + using next_s = typename Machine::template next_s; + + constexpr static auto run() { + if (std::is_same_v) { + return Machine{}; + } next::action(); + return next_s{}; } }; @@ -158,18 +164,24 @@ namespace obfs { using find = std::conditional_t< std::is_same_v, ST, Pass>; - using stage = typename First...>::type; + using stage = typename First...>::type; template - using next = typename stage::template next; + using next = std::conditional_t< + std::is_same_v, + None, + typename stage::template next>; template - using next_s = StateMachine::state, Specs...>; + using next_s = std::conditional_t< + std::is_same_v, None>, + None, + StateMachine::state, Specs...>>; template - constexpr static void run() { + constexpr static auto run() { using self = StateMachine; - MachineExecutor::run(); + return MachineExecutor::run(); } }; } diff --git a/obfuscator/obfs/fsm.hpp b/obfuscator/obfs/fsm.hpp index d7be67b..e0a87ae 100644 --- a/obfuscator/obfs/fsm.hpp +++ b/obfuscator/obfs/fsm.hpp @@ -55,19 +55,25 @@ namespace obfs { using next = typename Machine::template next; using next_s = typename Machine::template next_s; - constexpr static void run() { - if (next::action()) { - return; + constexpr static auto run() { + if (std::is_same_v || next::action()) { + return Machine{}; } - MachineExecutor::run(); + return MachineExecutor::run(); } }; template struct MachineExecutor { using next = typename Machine::template next; - constexpr static void run() { + using next_s = typename Machine::template next_s; + + constexpr static auto run() { + if (std::is_same_v) { + return Machine{}; + } next::action(); + return next_s{}; } }; @@ -77,18 +83,24 @@ namespace obfs { using find = std::conditional_t< std::is_same_v, ST, Pass>; - using stage = typename First...>::type; + using stage = typename First...>::type; template - using next = typename stage::template next; + using next = std::conditional_t< + std::is_same_v, + None, + typename stage::template next>; template - using next_s = StateMachine::state, Specs...>; + using next_s = std::conditional_t< + std::is_same_v, None>, + None, + StateMachine::state, Specs...>>; template - constexpr static void run() { + constexpr static auto run() { using self = StateMachine; - MachineExecutor::run(); + return MachineExecutor::run(); } }; }