Open pictyeye opened 10 years ago
In struct dump functions, the fields are not easily available as dump arguments. Today, a structure defined as follow is invalid
struct s { s_type : uint8; s_content : other_struct [s_type]; }
Indeed, in the generated parse function, the expression
let s_content = parse_other_struct s_type input
correctly refers to the first field that has just been parsed.
However, the generated dump function contains the expression
dump_other_struct s_type buf s.s_content
which should be
dump_other_struct s.s_type buf s.s_content
To allow direct and intuitive access to fields while dumping, it is proposed to prepend the dump calls in parse_struct with local definitions :
let s_type = s.s_type and s_content = s.s_content in
In struct dump functions, the fields are not easily available as dump arguments. Today, a structure defined as follow is invalid
Indeed, in the generated parse function, the expression
correctly refers to the first field that has just been parsed.
However, the generated dump function contains the expression
which should be
To allow direct and intuitive access to fields while dumping, it is proposed to prepend the dump calls in parse_struct with local definitions :