Descriptor for a constant value
Exemplo n.º 1
0
		internal CustomAttribute(MetaDataElement paren, Method constrType, 
				Constant val) {
			parent = paren;
			type = constrType;
			cVal = val;
			tabIx = MDTable.CustomAttribute;
		}
Exemplo n.º 2
0
		public void AddFieldOrProp(string name, Constant val) 
		{
			if (numNamed == 0) {
				names = new ArrayList();
				vals = new ArrayList();
			}
			names.Add(name);
			vals.Add(val);
		}
Exemplo n.º 3
0
		/// <summary>
		/// Add a value for this field
		/// </summary>
		/// <param name="val">the value for the field</param>
		public void AddValue(Constant val) 
		{
			constVal = new ConstantElem(this,val);
			flags |= HasDefault;
		}
Exemplo n.º 4
0
		internal ConstantElem(MetaDataElement parent, Constant val) 
		{
			this.parent = parent;
			cValue = val;
			tabIx = MDTable.Constant;
			sortTable = true;
		}
Exemplo n.º 5
0
		/// <summary>
		/// Add a custom attribute to this item
		/// </summary>
		/// <param name="ctorMeth">the constructor method for this attribute</param>
		/// <param name="val">the constant values of the parameters</param>
		public void AddCustomAttribute(Method ctorMeth, Constant[] cVals) 
		{
			if (customAttributes == null) {
				customAttributes = new ArrayList();
			} 
			//      customAttributes.Add(new CustomAttribute(this,ctorMeth,cVals));
		}
Exemplo n.º 6
0
		/// <summary>
		/// Add an initial value for this property
		/// </summary>
		/// <param name="constVal">the initial value for this property</param>
		public void AddInitValue(Constant constVal) 
		{
			this.constVal = new ConstantElem(this,constVal);
		}
Exemplo n.º 7
0
		/// <summary>
		/// Add a default value to this parameter
		/// </summary>
		/// <param name="c">the default value for the parameter</param>
		public void AddDefaultValue(Constant cVal) 
		{
			defaultVal = new ConstantElem(this,cVal);
			parMode |= (ushort) ParamAttr.HasDefault;
		}
Exemplo n.º 8
0
 /// <summary>
 /// Add a default value to this parameter
 /// </summary>
 /// <param name="c">the default value for the parameter</param>
 public void AddDefaultValue(Constant cVal) {
   defaultVal = new ConstantElem(this,cVal);
   parMode |= hasDefault;
 }
Exemplo n.º 9
0
		static byte[] ConstantToByteArray (Constant c)
		{
			var bac = c as ByteArrConst;
			if (bac != null)
				return bac.val;

			var ms = new MemoryStream ();
			// Version info
			ms.WriteByte (1);
			ms.WriteByte (0);

			if (c == null) {
				ms.WriteByte (0);
				ms.WriteByte (0);
				return ms.ToArray ();
			}

			var sc = c as StringConst;
			if (sc != null) {
				string value = sc.val;
				if (value == null)
					throw new NotImplementedException ();

				var buf = Encoding.UTF8.GetBytes (value);
				MetaData.CompressNum ((uint) buf.Length, ms);
				var byteVal = ms.ToArray ();
				System.Array.Resize (ref byteVal, (int) ms.Length + buf.Length + 2);
				System.Array.Copy (buf, 0, byteVal, ms.Length, buf.Length);
				return byteVal;
			}

			var ac = c as ArrayConstant;
			if (ac != null) {
				var bw = new BinaryWriter (ms);
				if (ac.ExplicitSize != null)
					bw.Write (ac.ExplicitSize.Value);
				ac.Write (bw);
				bw.Write ((short)0);
				return ms.ToArray ();
			}

			var bc = c as DataConstant;
			if (bc != null) {
				var bw = new BinaryWriter (ms);
				bc.Write (bw);
				bw.Write ((short)0);
				return ms.ToArray ();
			}

			throw new NotImplementedException (c.GetType ().ToString ());
		}
Exemplo n.º 10
0
		public void AddCustomAttribute (Method meth, Constant constant, MetaDataElement element)
		{
			metaData.AddCustomAttribute (new CustomAttribute (element, meth, constant));
			element.HasCustomAttr = true;
		}
Exemplo n.º 11
0
		internal CustomAttribute(MetaDataElement paren, Method constrType, 
				Constant val) {
			parent = paren;
			type = constrType;
			cVal = val;
			tabIx = MDTable.CustomAttribute;

			var bac = val as ByteArrConst;
			if (bac != null)
				byteVal = bac.val;
		}