toggle quoted messageShow quoted text
It is not just C, I think nearly all programming languages that have
ternary operator use C-like order: https://en.wikipedia.org/wiki/%3F:
I mean UEFI spec can define that '+' actually means '-', but what is the point?
At this time spec is already written and this is just a rhetorical
question to the specification creators.
I just wonder if there is any thought behind this. Maybe this opcode
sequence produces results that are easier to parse, or something like
On Mon, Jul 4, 2022 at 4:29 AM gaoliming <gaoliming@...> wrote:
VFR syntax exactly matches this opcode definition in UEFI spec. It is not same to C language ? expression.
发件人: firstname.lastname@example.org <email@example.com> 代表
发送时间: 2022年7月1日 23:34
收件人: discuss <firstname.lastname@example.org>
主题: Re: [edk2-discuss] Strange behaviour with VFR read and cond
Ok, it looks like I've found the source of error.
According to the UEFI specification:
This opcode performs the following actions:
1. Pop three values from the expression stack. The first value popped
is the right value. The
second expression popped is the middle value. The last expression
popped is the left value.
2. If the left value cannot be evaluated as a boolean, push Undefined.
3. If the left expression evaluates to TRUE, push the right value.
4. Otherwise, push the middle value.
So "cond( A? B: C)" is not equal to "A? B: C" ternary operator in
standard programming languages, but it gives quite the opposite
behaviour "A? C: B"
Why is it done this way? It looks very misleading to me.
On Fri, Jul 1, 2022 at 6:12 PM Konstantin Aladyshev
Can someone explain what is wrong with this code?
The intention is this:
- if option3 is selected, numeric value is always equal 20 and user
can't change it
- if option1 or option2 is selected, user can change numeric value
But in fact I see the opposite behaviour:
- if option1 or option2 is selected, numeric value is 20 and it is not
possible to change it
- if option3 is selected user can change numeric value
varid = FormData.OneOfValue,
prompt = STRING_TOKEN(ONEOF_PROMPT),
help = STRING_TOKEN(ONEOF_HELP),
option text = STRING_TOKEN(ONEOF_OPTION1), value = 0x00, flags =
option text = STRING_TOKEN(ONEOF_OPTION2), value = 0x33, flags = 0;
option text = STRING_TOKEN(ONEOF_OPTION3), value = 0x55, flags = 0;
varid = FormData.NumericValue,
prompt = STRING_TOKEN(NUMERIC_PROMPT),
help = STRING_TOKEN(NUMERIC_HELP),
flags = NUMERIC_SIZE_2,
minimum = 0x0,
maximum = 0xffff,
step = 1,
read cond((get(FormData.OneOfValue) == 0x55) ? 20 : pushthis);
What am I missing?