Skip to content

Instantly share code, notes, and snippets.

@leppie
Created October 27, 2015 15:43
Show Gist options
  • Save leppie/ce1b50a383c48a4662a0 to your computer and use it in GitHub Desktop.
Save leppie/ce1b50a383c48a4662a0 to your computer and use it in GitHub Desktop.
New way of loading array data for bignums
private void EmitMetadataArray(uint[] p)
{
var size = p.Length * 4;
byte[] data = new byte[size];
Buffer.BlockCopy(p, 0, data, 0, size);
var fb = this._typeGen.TypeBuilder.DefineInitializedData(Guid.NewGuid().ToString(), data, FieldAttributes.Static);
EmitInt(p.Length);
Emit(OpCodes.Newarr, typeof(uint));
Emit(OpCodes.Dup);
Emit(OpCodes.Ldtoken, fb);
EmitCall(typeof(System.Runtime.CompilerServices.RuntimeHelpers).GetMethod("InitializeArray"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment