decomp-permuter
decomp-permuter copied to clipboard
Struct nesting / flattening randomization
Nesting
The permuter should be able to create substructs by nesting fields from a larger struct. For example:
typedef struct {
int foo;
int bar;
int baz;
} FooBarBaz;
can become
typedef struct {
int foo;
int bar;
} FooBar;
typedef struct {
FooBar foobar;
int baz;
} FooBarBaz;
Flattening
Similarly, the permuter should be able to flatten fields from a nested struct. After selecting the substruct, it should attempt to either flatten some of the upper fields upwards or some of the lower fields downwards. For example:
typedef struct {
int foo;
int bar;
int baz;
} FooBarBaz;
typedef struct {
FooBarBaz fooBarBaz;
int qux;
} FooBarBazQux;
can become
typedef struct {
int bar;
int baz;
} BarBaz;
typedef struct {
int foo;
BarBaz barBaz;
int qux;
} FooBarBazQux;
or it could become
typedef struct {
int foo;
int bar;
} FooBar;
typedef struct {
FooBar fooBar;
int baz;
int qux;
} FooBarBazQux;