|
Just want to make sure I understand for what things I need to get tokens and insert them into the byte code stream I am generating. I believe it is anything that is referenced in the byte code stream that would have a metadata token associated with it. Working from the overloads for the GetTokenFormethod documented in msdn, that would then be any:
byte array,
other dynamic method being invoked,
field being accessed,
assembly-based method being invoked,
type,
string
method on a generic type
Before submitting a custom-generated byte code sequence I would want to resolve the metadata tokens for any of these items. And so if I keep my generated byte code along with a record of those offsets that need to be resolved and the particular metadata needed to resolve them, then I should be able to feed this structure to a resolving method that would call GetTokenForand finalize the byte code stream at the time I am using it to generate an actual dynamic method. This way I could achieve my goal of assembling different configurations of highly factored core byte code streams and avoid having topackage each factored unit into its own callable method. My system alreadydoes this with assembly code and with my own virtual machine byte codes and I would liketo extend it to work with CLI byte codes as well.
Anything you see wrong with this picture? You mentioned in a response to my previous post that it was "dangerous" to hold on to generated byte code streams. Metadata token issues aside, is there something else I should be concerned about? |