Bring jbevain/cecil's commit a2c944bd45b81443fd61cfd27d98ff551fa6938c, Add enum value...
[mono.git] / mcs / class / Mono.Cecil / Mono.Cecil / TypeDefinition.cs
index c83531a0567a5adf8ff038b2733b1f948cbc9541..4079406d4054087f9004bbecf9d143d5201db1dc 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //   Jb Evain (jbevain@gmail.com)
 //
-// Copyright (c) 2008 - 2010 Jb Evain
+// Copyright (c) 2008 - 2011 Jb Evain
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -27,7 +27,7 @@
 //
 
 using System;
-
+using Mono.Cecil.Metadata;
 using Mono.Collections.Generic;
 
 namespace Mono.Cecil {
@@ -161,10 +161,6 @@ namespace Mono.Cecil {
                        }
                }
 
-               internal new bool HasImage {
-                       get { return Module != null && Module.HasImage; }
-               }
-
                public bool HasMethods {
                        get {
                                if (methods != null)
@@ -392,6 +388,11 @@ namespace Mono.Cecil {
                        set { attributes = attributes.SetAttributes ((uint) TypeAttributes.Serializable, value); }
                }
 
+               public bool IsWindowsRuntime {
+                       get { return attributes.GetAttributes ((uint) TypeAttributes.WindowsRuntime); }
+                       set { attributes = attributes.SetAttributes ((uint) TypeAttributes.WindowsRuntime, value); }
+               }
+
                public bool IsAnsiClass {
                        get { return attributes.GetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass); }
                        set { attributes = attributes.SetMaskedAttributes ((uint) TypeAttributes.StringFormatMask, (uint) TypeAttributes.AnsiClass, value); }
@@ -437,6 +438,23 @@ namespace Mono.Cecil {
                        }
                }
 
+               public override bool IsPrimitive {
+                       get {
+                               ElementType primitive_etype;
+                               return MetadataSystem.TryGetPrimitiveElementType (this, out primitive_etype);
+                       }
+               }
+
+               public override MetadataType MetadataType {
+                       get {
+                               ElementType primitive_etype;
+                               if (MetadataSystem.TryGetPrimitiveElementType (this, out primitive_etype))
+                                       return (MetadataType) primitive_etype;
+
+                               return base.MetadataType;
+                       }
+               }
+
                public override bool IsDefinition {
                        get { return true; }
                }