Greg Beech's Website

Browse by Tags

  • Emitting primitive type conversions with Reflection.Emit

    Conversion between primitive types is trivial in high-level languages like C# as you can use the cast operator, optionally surrounded with checked or unchecked to force the integer overflow semantics. At CIL level the conversion is less trivial, involving the choice of no fewer than 27 different op-codes, which are required to be used in combination with each other under some circumstances. This is...
  • Emitting arbitrary constants with Reflection.Emit

    I've been writing a fair bit of Reflection.Emit code recently, and along the way have developed quite a number of extension methods for the ILGenerator class to handle the complex semantics of some seemingly trivial operations , and choose the most efficient op-codes (e.g. when can the short forms be used). I had already written EmitLdc methods to handle constant values for every type that can...
  • Emitting decimal pseudo-constants with Reflection.Emit

    Some languages such as C# let you treat the System.Decimal type as an integral type most of the time, even having the keyword decimal , and will let you declare constant fields of the type under some circumstances. However, decimal isn't a primitive type in the same way as the other numerics, and is implemented quite differently from them. At CIL level, you can't actually declare a constant...
Copyright (C) Greg Beech. All rights reserved.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems