#pragma once #include #include // // Put the transform in its own namespace // just to keep the header files easy to read. // This is not an IRDB transform requirement, just good coding practice. // namespace InitStack { using namespace std; using namespace IRDB_SDK; // // This class handles initializing stack frames to a constant value // // Note: Using private inheritence here for "principle of minimum access", // but you can choose what's best for your needs. // class InitStack_t : private Transform_t { public: // construct an object InitStack_t( FileIR_t *p_variantIR, // the FileIR object to transform const string &p_function_filename, // the name of a file with functions to // transform. "" -> no file and // transform all functions int init_value = 0, // the value to write when initializing the stack bool p_verbose = false // use verbose logging? ); // execute the transform // input: m_funcs_to_init the set of functions to transform, the fileIR to // transform output: the transformed fileIR, with extra instructions to init // stack frames return value: true -> success, false -> fail bool execute(); private: // methods // read in the given file full of function names to transform (called from // constructor) input: the filename and FileIR to transform output: // m_funcs_to_init with the functions listed in the file void readFunctionsFromFile(const string &p_filename); // initialize the stack for a given function // input: the fileIR to transform // output: the transformed fileIR void initStack(Function_t *f); // data set m_funcs_to_init; // the functions whose stacks this object // should initialize int m_init_value; // the value with which to init the stack. bool m_verbose; // do verbose logging int m_num_transformed; // stats about how many functions that this object has // transformed }; } // namespace InitStack