Пример #1
0
        internal MethodReference(string name, bool hasThis,
			bool explicitThis, MethodCallingConvention callConv)
            : this(name)
        {
            m_parameters = new ParameterDefinitionCollection (this);
            m_hasThis = hasThis;
            m_explicitThis = explicitThis;
            m_callConv = callConv;
        }
Пример #2
0
        public static bool AreSame(ParameterDefinitionCollection a, ParameterDefinitionCollection b)
        {
            if (a.Count != b.Count)
                return false;

            if (a.Count == 0)
                return true;

            for (int i = 0; i < a.Count; i++)
                if (!AreSame (a [i].ParameterType, b [i].ParameterType))
                    return false;

            return true;
        }
        protected void AddParameters(ParameterDefinitionCollection tmpParameters)
        {
            foreach (ParameterDefinition parameterDefinition in tmpParameters)
            {
                if (parameters.ContainsKey(parameterDefinition.Name))
                {
                    Logger.Warning("Methods can't have more than one parameter with the same name.");
                    return;
                }

                parametersNames.Add(parameterDefinition.Name);
                parameters.Add(parameterDefinition.Name, new MyParameterInfo(parameterDefinition));
            }
        }
Пример #4
0
    private static string BuildParameterList(ParameterDefinitionCollection parameterDefinitionCollection)
    {
      var sb = new StringBuilder();
      int paramCount = 1;
      foreach (ParameterDefinition paramDef in parameterDefinitionCollection)
      {
        sb.Append(paramDef.ParameterType.Name);

        if (paramCount < parameterDefinitionCollection.Count)
        {
          sb.Append(",");
          paramCount++;
        }
      }

      return sb.ToString();
    }
        private void SaveConstructorArguments(CilWorker IL, ParameterDefinitionCollection parameters)
        {
            var parameterCount = parameters.Count;

            IL.Emit(OpCodes.Newobj, _objectListCtor);
            IL.Emit(OpCodes.Stloc, _constructorArguments);

            var index = parameterCount - 1;
            while (index >= 0)
            {
                var param = parameters[index];

                SaveConstructorArgument(IL, param);

                index--;
            }

            // Reverse the constructor arguments so that they appear in the correct order
            IL.Emit(OpCodes.Ldloc, _constructorArguments);
            IL.Emit(OpCodes.Callvirt, _reverseMethod);
        }
Пример #6
0
        public override void VisitParameterDefinitionCollection(ParameterDefinitionCollection parameters)
        {
            if (parameters.Count == 0)
                return;

            ushort seq = 1;
            ParamTable pTable = m_tableWriter.GetParamTable ();
            foreach (ParameterDefinition param in parameters)
                InsertParameter (pTable, param, seq++);
        }
Пример #7
0
 Param[] GetParametersSig(ParameterDefinitionCollection parameters)
 {
     Param [] ret = new Param [parameters.Count];
     for (int i = 0; i < ret.Length; i++) {
         ParameterDefinition pDef = parameters [i];
         Param p = new Param ();
         p.CustomMods = GetCustomMods (pDef.ParameterType);
         if (pDef.ParameterType.FullName == Constants.TypedReference)
             p.TypedByRef = true;
         else if (pDef.ParameterType is ReferenceType) {
             p.ByRef = true;
             p.Type = GetSigType (
                 (pDef.ParameterType as ReferenceType).ElementType);
         } else
             p.Type = GetSigType (pDef.ParameterType);
         ret [i] = p;
     }
     return ret;
 }
		public MethodDefinition GetMethod (string name, ParameterDefinitionCollection parameters)
		{
			return GetMethodInternal (name, parameters);
		}
		ParameterDefinitionCollection CloneParameterCollection (ParameterDefinitionCollection original)
		{
			ParameterDefinitionCollection clone = new ParameterDefinitionCollection (
				original.Container);
			foreach (ParameterDefinition param in original)
				clone.Add (param);
			return clone;
		}
Пример #10
0
		public ParameterData (XmlDocument document, XmlNode parent, ParameterDefinitionCollection parameters)
			: base (document, parent)
		{
			this.parameters = parameters;
		}
 public MethodDefinition GetMethod(string name, ParameterDefinitionCollection parameters)
 {
     foreach (MethodDefinition meth in this)
         if (meth.Name == name && meth.Parameters.Count == parameters.Count) {
             if (parameters.Count == 0)
                 return meth;
             for (int i = 0; i < parameters.Count; i++)
                 if (meth.Parameters [i].ParameterType.FullName == parameters [i].ParameterType.FullName)
                     return meth;
         }
     return null;
 }
        private void InitializeParameters(DefineParameterDelegate defineParameter, ParameterDefinitionCollection parameterDefinitions)
        {
            foreach (ParameterDefinition parameterDefinition in parameterDefinitions)
            {
                ParameterBuilder parameterBuilder = defineParameter(parameterDefinition.Sequence,
                    (System.Reflection.ParameterAttributes)parameterDefinition.Attributes, parameterDefinition.Name);

                if (parameterDefinition.HasConstant)
                    parameterBuilder.SetConstant(parameterDefinition.Constant);

                metadataPass.Add(delegate
                {
                    InitializeCustomAttributes(parameterBuilder.SetCustomAttribute, parameterDefinition.CustomAttributes);
                });
            }
        }
Пример #13
0
		public override void VisitParameterDefinitionCollection (ParameterDefinitionCollection parameters)
		{
			int i = 0;
			foreach (ParameterDefinition param in parameters) {
				//FIXME: do param.Accept ?
				if(i++ > 0) m_writer.BaseWriter.Write(", ");
				VisitParameterDefinition (param);
			}
		}
Пример #14
0
 public MethodDefinition GetConstructor(bool isStatic, ParameterDefinitionCollection parameters)
 {
     return(GetConstructorInternal(isStatic, parameters));
 }
Пример #15
0
        private void AddParameters(MethodDefinition getterInfo, MethodDefinition setterInfo)
        {
            ParameterDefinitionCollection propParameters = null;

            if (getterInfo != null)
            {
                propParameters = getterInfo.Parameters;
            }
            else if (setterInfo != null)
            {
                ParameterDefinitionCollection tmpParameters = setterInfo.Parameters;

                Debug.Assert(tmpParameters != null && tmpParameters.Count >= 1, "Impossible! Property setter must have at least one parameter.");

                propParameters = new ParameterDefinitionCollection(setterInfo);

                for (int i = 0; i < tmpParameters.Count - 1; i++)
                {
                    propParameters.Add(tmpParameters[i]);
                }
            }
            else
            {
                Debug.Assert(false, "Impossible! Property must have either getter or setter or both.");
            }

            foreach (ParameterDefinition parameterDefinition in propParameters)
            {
                if (parameters.ContainsKey(parameterDefinition.Name))
                {
                    Logger.Warning("Properties can't have more than one parameter with the same name.");
                    return;
                }

                parametersNames.Add(parameterDefinition.Name);
                parameters.Add(parameterDefinition.Name, new MyParameterInfo(parameterDefinition));
            }
        }
		public override void VisitParameterDefinitionCollection (ParameterDefinitionCollection parameters)
		{
			VisitCollection (parameters);
		}
Пример #17
0
			void AddParameters(IMethodOrProperty target, ParameterDefinitionCollection plist)
			{
				foreach (ParameterDefinition par in plist) {
					IReturnType pReturnType = CreateType(this.ProjectContent, target, par.ParameterType);
					DefaultParameter p = new DefaultParameter(par.Name, pReturnType, DomRegion.Empty);
					if ((par.Attributes & ParameterAttributes.Out) == ParameterAttributes.Out) {
						p.Modifiers = ParameterModifiers.Out;
					} else if (par.ParameterType is ReferenceType) {
						p.Modifiers = ParameterModifiers.Ref;
					} else {
						p.Modifiers = ParameterModifiers.In;
					}
					if ((par.Attributes & ParameterAttributes.Optional) == ParameterAttributes.Optional) {
						p.Modifiers |= ParameterModifiers.Optional;
					}
					if (p.ReturnType.IsArrayReturnType) {
						foreach (CustomAttribute att in par.CustomAttributes) {
							if (att.Constructor.DeclaringType.FullName == typeof(ParamArrayAttribute).FullName) {
								p.Modifiers |= ParameterModifiers.Params;
							}
						}
					}
					target.Parameters.Add(p);
				}
			}
Пример #18
0
 private void AddUsedTypesFromParameters(ParameterDefinitionCollection Parameters, List<UsedClass> usedT)
 {
     foreach (ParameterDefinition param in Parameters)
     {
         AddTypeToList(param.ParameterType, ClassUse.Parameter, usedT);
     }
 }
Пример #19
0
		public static string GetSignature (ParameterDefinitionCollection infos)
		{
			if (infos == null || infos.Count == 0)
				return "";

			var signature = new StringBuilder ();
			for (int i = 0; i < infos.Count; i++) {

				if (i > 0)
					signature.Append (", ");

				ParameterDefinition info = infos [i];

				string modifier;
				if ((info.Attributes & ParameterAttributes.In) != 0)
					modifier = "in";
				else if ((info.Attributes & ParameterAttributes.Retval) != 0)
					modifier = "ref";
				else if ((info.Attributes & ParameterAttributes.Out) != 0)
					modifier = "out";
				else
					modifier = string.Empty;

				if (modifier.Length > 0)
					signature.AppendFormat ("{0} ", modifier);

				signature.Append (Utils.CleanupTypeName (info.ParameterType));
			}

			return signature.ToString ();
		}
 public virtual void VisitParameterDefinitionCollection(ParameterDefinitionCollection parameters)
 {
     foreach (ParameterDefinition param in parameters)
     {
         VisitParameterDefinition(param);
     }
 }
Пример #21
0
 public virtual void VisitParameterDefinitionCollection(ParameterDefinitionCollection parameters)
 {
 }
        public virtual void VisitParameterDefinitionCollection(ParameterDefinitionCollection parameters)
        {

        }
Пример #23
0
 public MethodDefinition GetConstructor(bool isStatic, ParameterDefinitionCollection parameters)
 {
     return GetConstructorInternal (isStatic, parameters);
 }
 public MethodDefinition GetMethod(string name, ParameterDefinitionCollection parameters)
 {
     return(GetMethodInternal(name, parameters));
 }