The expression syntax follows closely, the expression syntax and precedence of C as defined in the ISO/IEC 9899:TC2 document. Since the EDK II meta-data files are not parsed as C code, but rather as script files, some of the items listed in the C expression section (6.5) do not apply. Also, some of the items have been extended to use scripting syntax for logical comparison operators such as "EQ" as a synonym for "==".
The Conditional directive section is loosely based on section 6.10, Preprocessing directives. Again, some of the items listed in the Preprocessing directives section do not apply.
-
Prior to evaluation, all macro values, PCD values and defined literals (such as TRUE or FALSE) used in the expression must be resolved. The only exception to this rule is when a macro value assignment contains an expression. In this case, an expression on the right side of the assignment operator ("=") must have all values resolved in the expression's operands prior to evaluation and subsequent assignment. In this instance, in order to have the operand values resolved, the tools may be required to perform more than one pass over a file to obtain values for the operands.
-
Floating point values are not supported under PCD datum types.
-
When used in an expression, a PCD's value is used during evaluation.
-
An expression is a sequence of operators and operands that specifies computation of a value.
-
Between the previous and next sequence, an object shall have its stored value modified at most once by the evaluation of an expression.
-
Some operators (the unary operator, ~, and the binary operators,
<<, >>
, &, | and ^ collectively described as bitwise operators) are required to have operands that are integer (base10) or hexadecimal (base16) types. -
The unary arithmetic operators, +, - and ~ must have an operand that is an integer (base10) or hexadecimal (base16) type, while the scalar unary operators, ! and NOT, must have operands that are of type scalar.
-
The Boolean values, False, FALSE and false have a numerical value of zero. The Boolean values, True, TRUE and true have a numerical value of one.
-
Tools may be required to translate the expression sequence into an expression format that is comprehended by the tool's native language. For example, a tool written in Python may require changing the exact syntax of an expression to a syntax that can be processed by Python's eval() function.
-
Multiplicative and additive operators require both operands to be arithmetic in type.
-
Relational and equality operators require both operands to be of the same type. The single quote string and double quote string are same type as general string, while the string start with
L
character is the unicode string. Unicode string should not compare with general string. Relational comparison on string literals and byte arrays must be performed comparing the byte values, left to right. The first pair of bytes (or a single extra byte) that is not equal will determine the result of the comparison. The following are examples of string comparisons:Foo = "zero", Bar = "three";
Foo < Bar
will evaluate to zero (AKA, FALSE), as "z" is greater than "t".Foo = "thirty", Bar = "thirty1";`
Foo < Bar
will evaluate to one (AKA, TRUE), as Bar has an extra character. -
Logical operators require operands that are type scalar.
-
For the Conditional Operator, the first operand must be scalar, while the second and third operands must have the same type (i.e., both being scalar, both being integers, or both being string literals).
-
Array format like "{0x10, 0x20}" can't be a operand of any operator except Relational and equality operators.