Logical instructions for CIL
How can I 开发者_JAVA百科use logical operators like AND, OR, NOT in CIL ?
There are no CIL opcodes for those operators; you need to implement them via conditional branching instead. For instance, a && b
is the same as a ? b : false
, and a || b
is the same as a ? true : b
, both of which are relatively easy to implement in IL (e.g. you can use the brtrue
opcode to do a conditional jump based on the value of a
).
精彩评论