Commit 13e1730
committed
Support conditional fields and variable-length arrays in the Wireshark Lua backend
Add an Emboss-expression -> Lua translator so the dissector backend can
handle constructs it previously skipped:
* Conditional (`if`) fields are emitted as `if <cond> then ... end`.
* Variable-length arrays (`T[n]`, with `n` a sibling field) and
dynamically-located fields are emitted with the length/offset
expression translated to Lua.
Sibling field values referenced by a condition, array length, or offset are
captured into `local val_*` reads. Fields whose governing expression can't be
translated are still skipped with a comment, so the generator always emits
valid Lua. Constant-only structs produce byte-identical output to before.
Add testdata/wireshark_dynamic.emb (and its golden), expression/conditional/
array unit tests, and a TShark smoke test that loads a generated dissector
and checks both branches of a conditional, length-prefixed message (the test
skips itself when tshark is not installed).1 parent c962481 commit 13e1730
8 files changed
Lines changed: 735 additions & 80 deletions
File tree
- compiler/back_end/lua
- scripts
- testdata
- golden_lua
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
69 | 82 | | |
70 | 83 | | |
71 | 84 | | |
| |||
109 | 122 | | |
110 | 123 | | |
111 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
0 commit comments