Descriptionbpf_dsl: support Switch/Case expressions
This adds support for expressions like
Switch(arg)
.Case(1, result1)
.CASES((2, 3), result2)
.Default(result3)
Currently these expressions are compiled simply as short-hand for
If(arg == 1, result1)
.ElseIf(arg == 2 || arg == 3, result2)
.Else(result3)
but in the future we should be able to optimize it better.
The CASES macro ugliness is unfortunately necessary until we're
allowed to use C++11. Later we'll be able to change it to
real C++ code like "Cases({2, 3}, result2)" (which clang-format
will then format a bit more nicely too).
BUG=408845
R=jln@chromium.org, jorgelo@chromium.org
Committed: https://chromium.googlesource.com/chromium/src/+/279b9aad9824c840e10382c2f6e4356d4c632774
Patch Set 1 #Patch Set 2 : Rename multi-value Case to Cases; tweak implementation #Patch Set 3 : Cleanup #Patch Set 4 : Minor style tweak #Patch Set 5 : Rename helper macro #Patch Set 6 : Sync and resolve conflicts #
Total comments: 2
Patch Set 7 : Sync and resolve conflicts #
Messages
Total messages: 9 (0 generated)
|