diff options
author | jfrijters <jfrijters> | 2011-03-08 11:41:00 +0300 |
---|---|---|
committer | jfrijters <jfrijters> | 2011-03-08 11:41:00 +0300 |
commit | 20ee69de0c8f7faada6a01cedde07f93d77efdbe (patch) | |
tree | b1a1a0906e9d7e41b74b5d1f0679bb0db7d9f5de /reflect/Emit | |
parent | 3a47da1a454860e4708e58c7da55c9b72a02a9c2 (diff) |
Added FieldBuilder.__SetReadOnlyDataAndRVA() to define read-only initialized data.
Diffstat (limited to 'reflect/Emit')
-rw-r--r-- | reflect/Emit/FieldBuilder.cs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/reflect/Emit/FieldBuilder.cs b/reflect/Emit/FieldBuilder.cs index 92205542..67ea8ae8 100644 --- a/reflect/Emit/FieldBuilder.cs +++ b/reflect/Emit/FieldBuilder.cs @@ -65,13 +65,23 @@ namespace IKVM.Reflection.Emit public void __SetDataAndRVA(byte[] data) { + SetDataAndRvaImpl(data, typeBuilder.ModuleBuilder.initializedData, 0); + } + + public void __SetReadOnlyDataAndRVA(byte[] data) + { + SetDataAndRvaImpl(data, typeBuilder.ModuleBuilder.methodBodies, unchecked((int)0x80000000)); + } + + private void SetDataAndRvaImpl(byte[] data, ByteBuffer bb, int readonlyMarker) + { attribs |= FieldAttributes.HasFieldRVA; FieldRVATable.Record rec = new FieldRVATable.Record(); - typeBuilder.ModuleBuilder.initializedData.Align(8); - rec.RVA = typeBuilder.ModuleBuilder.initializedData.Position; + bb.Align(8); + rec.RVA = bb.Position + readonlyMarker; rec.Field = pseudoToken; typeBuilder.ModuleBuilder.FieldRVA.AddRecord(rec); - typeBuilder.ModuleBuilder.initializedData.Write(data); + bb.Write(data); } public override void __GetDataFromRVA(byte[] data, int offset, int length) |