Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2015-06-01 15:52:11 +0300
committerMarek Safar <marek.safar@gmail.com>2015-06-01 15:53:16 +0300
commit3f6b3e46b48e3f6463c6819679a7e6bd6b53f09d (patch)
treea37eb9dc817d9485b67f27532453eae24665f2d6 /mcs/class/PEAPI
parent54e8010aadb4fe69d216a5835c7b01f6187f745e (diff)
[ilasm] Add support for undocumented modopt/modreq using primitive types
Diffstat (limited to 'mcs/class/PEAPI')
-rw-r--r--mcs/class/PEAPI/Metadata.cs36
-rw-r--r--mcs/class/PEAPI/PEAPI.cs5
2 files changed, 40 insertions, 1 deletions
diff --git a/mcs/class/PEAPI/Metadata.cs b/mcs/class/PEAPI/Metadata.cs
index 041b3392ef4..c2351247660 100644
--- a/mcs/class/PEAPI/Metadata.cs
+++ b/mcs/class/PEAPI/Metadata.cs
@@ -3314,6 +3314,7 @@ namespace PEAPI {
Type type;
Class cmodType;
+ PrimitiveTypeRef cmodPrimType;
/// <summary>
/// Create a new custom modifier for a type
@@ -3328,10 +3329,23 @@ namespace PEAPI {
this.cmodType = cmodType;
}
+ public CustomModifiedType(Type type, CustomModifier cmod, PrimitiveTypeRef cmodType)
+ : base((byte)cmod)
+ {
+ this.type = type;
+ this.cmodPrimType = cmodType;
+ }
+
internal sealed override void TypeSig(MemoryStream str)
{
str.WriteByte(typeIndex);
- MetaData.CompressNum(cmodType.TypeDefOrRefToken(),str);
+
+ if (cmodType != null) {
+ MetaData.CompressNum(cmodType.TypeDefOrRefToken(),str);
+ } else {
+ MetaData.CompressNum(cmodPrimType.TypeDefOrRefToken(),str);
+ }
+
type.TypeSig(str);
}
@@ -4470,6 +4484,26 @@ namespace PEAPI {
}
+ public class PrimitiveTypeRef : Type
+ {
+ PrimitiveType type;
+ MetaData metaData;
+
+ internal PrimitiveTypeRef(PrimitiveType type, MetaData md)
+ : base (0)
+ {
+ this.type = type;
+ this.metaData = md;
+ }
+
+ internal uint TypeDefOrRefToken()
+ {
+ uint cIx = type.GetTypeSpec (metaData).Row;
+ cIx = (cIx << 2) | 0x2;
+ return cIx;
+ }
+ }
+
/**************************************************************************/
/// <summary>
/// Descriptor for an pointer (type * or type &)
diff --git a/mcs/class/PEAPI/PEAPI.cs b/mcs/class/PEAPI/PEAPI.cs
index 3043b3a6ea5..ec3cb410717 100644
--- a/mcs/class/PEAPI/PEAPI.cs
+++ b/mcs/class/PEAPI/PEAPI.cs
@@ -923,6 +923,11 @@ namespace PEAPI {
return file;
}
+ public PrimitiveTypeRef AddPrimitiveType (PrimitiveType type)
+ {
+ return new PrimitiveTypeRef (type, metaData);
+ }
+
/// <summary>
/// Add a manifest resource to this PEFile NOT YET IMPLEMENTED
/// </summary>