예제 #1
0
        bool ISupportsInterning.EqualsForInterning(ISupportsInterning other)
        {
            DefaultUnresolvedParameter p = other as DefaultUnresolvedParameter;

            return(p != null && type == p.type && attributes == p.attributes && name == p.name &&
                   defaultValue == p.defaultValue && region == p.region && flags == p.flags);
        }
        bool ISupportsInterning.EqualsForInterning(ISupportsInterning other)
        {
            // compare everything except for the IsFrozen flag
            DefaultUnresolvedParameter p = other as DefaultUnresolvedParameter;

            return(p != null && type == p.type && name == p.name &&
                   defaultValue == p.defaultValue && region == p.region && (flags & ~1) == (p.flags & ~1) && ListEquals(attributes, p.attributes));
        }
        static void AddPlaceholders(Step action, IUnresolvedMethod method)
        {
            var parameters = new List<IUnresolvedParameter> ();

            int index = 0;

            foreach (var placeholder in action.Placeholders) {
                var typeRef = new DefaultUnresolvedTypeDefinition (placeholder.Name);

                var p =  new DefaultUnresolvedParameter (typeRef, "p" + index);

                method.Parameters.Add (p);

                index++;
            }
        }
예제 #4
0
		static IUnresolvedMethod FunctionToIMethod (ProjectInformation pi, IUnresolvedTypeDefinition type, Function function, string[] contentLines)
		{
			var method = new DefaultUnresolvedMethod (type, function.Name);
			method.Region = new DomRegion ((int)function.Line, 1, FindFunctionEnd (contentLines, (int)function.Line-1)+2, 1);
			
			Match match;
			bool abort = false;
			var parameters = new List<IUnresolvedParameter> ();
			foreach (string parameter in function.Parameters) {
				match = paramExpression.Match (parameter);
				if (null == match) {
					abort = true;
					break;
				}
				var typeRef = new DefaultUnresolvedTypeDefinition (string.Format ("{0}{1}{2}", match.Groups["type"].Value, match.Groups["subtype"].Value, match.Groups["array"].Value));
				var p =  new DefaultUnresolvedParameter (typeRef, match.Groups["name"].Value);
				parameters.Add (p);
			}
			if (!abort)
				parameters.ForEach (p => method.Parameters.Add (p));
			return method;
		}
예제 #5
0
        void AddAttributes(ParameterInfo parameter, DefaultUnresolvedParameter targetParameter)
        {
            if (!targetParameter.IsOut) {
                if (parameter.IsIn)
                    targetParameter.Attributes.Add(inAttribute);
                if (parameter.IsOut)
                    targetParameter.Attributes.Add(outAttribute);
            }
            AddCustomAttributes(parameter.CustomAttributes, targetParameter.Attributes);

            FieldMarshal marshalInfo;
            if (parameter.__TryGetFieldMarshal (out marshalInfo)) {
                targetParameter.Attributes.Add(ConvertMarshalInfo(marshalInfo));
            }
        }
예제 #6
0
        public IUnresolvedParameter ReadParameter(ParameterInfo parameter)
        {
            if (parameter == null)
                throw new ArgumentNullException("parameter");
            var type = ReadTypeReference(parameter.ParameterType, typeAttributes: parameter.CustomAttributes);
            var p = new DefaultUnresolvedParameter(type, interningProvider.Intern(parameter.Name ?? "index"));

            if (parameter.ParameterType.IsByRef) {
                if (!parameter.IsIn && parameter.IsOut)
                    p.IsOut = true;
                else
                    p.IsRef = true;
            }
            AddAttributes(parameter, p);

            if (parameter.IsOptional) {
                p.DefaultValue = CreateSimpleConstantValue(type, parameter.RawDefaultValue);
            }

            if (parameter.ParameterType.IsArray) {
                foreach (var att in parameter.CustomAttributes) {
                    if (att.AttributeType.FullName == typeof(ParamArrayAttribute).FullName) {
                        p.IsParams = true;
                        break;
                    }
                }
            }

            return interningProvider.Intern(p);
        }
예제 #7
0
        public IUnresolvedParameter ReadParameter(ParameterInfo parameter)
        {
            if (parameter == null)
                throw new ArgumentNullException("parameter");
            var customAttributes = parameter.CustomAttributes;
            var parameterType = parameter.ParameterType;
            var type = ReadTypeReference(parameterType, typeAttributes: customAttributes);
            var p = new DefaultUnresolvedParameter(type, interningProvider.Intern(parameter.Name ?? "index"));

            if (parameterType.IsByRef) {
                if (!parameter.IsIn && parameter.IsOut)
                    p.IsOut = true;
                else
                    p.IsRef = true;
            }
            AddAttributes(parameter, p, customAttributes);

            if (parameter.IsOptional) {
                p.DefaultValue = CreateSimpleConstantValue(type, parameter.RawDefaultValue);
            }

            if (parameterType.IsArray) {
                foreach (var att in customAttributes) {
                    var dt = att.Constructor.DeclaringType;
                    if (dt.__Name == "ParamArrayAttribute" && dt.Namespace == "System") {
                        p.IsParams = true;
                        break;
                    }
                }
            }

            return interningProvider.Intern(p);
        }
예제 #8
0
		//TODO: handle generics
		public static IUnresolvedMethod CodeDomToMDDomMethod (CodeMemberMethod method)
		{
			var meth = new DefaultUnresolvedMethod (null, method.Name);
			meth.ReturnType = new DefaultUnresolvedTypeDefinition (method.ReturnType.BaseType);
			
			CodeDomModifiersToMDDom (meth, method.Attributes);
			
			foreach (CodeParameterDeclarationExpression dec in method.Parameters) {
				var paramType = new DefaultUnresolvedTypeDefinition (dec.Type.BaseType);
				var par = new  DefaultUnresolvedParameter (paramType, dec.Name);
				if (dec.Direction == FieldDirection.Ref)
					par.IsRef = true;
				else if (dec.Direction == FieldDirection.Out)
					par.IsOut = true;
				meth.Parameters.Add (par);
			}
			
			return meth;
		}
 static IUnresolvedParameter TransformParameterInfo(ArgumentAnnotation argAnnotation)
 {
     var name = argAnnotation.Name;
     bool has_variable_params = false;
     if(name.EndsWith(".")){		//parameter names that end with trailing "..." indicate that the parameters can take arbitrary number of arguments
         has_variable_params = true;
         name = name.Substring(0, name.Length - 3);
     }
     var param = new DefaultUnresolvedParameter(PrimitiveTypeReference.Get(argAnnotation.ParamType), name);
     param.IsParams = has_variable_params;
     return param;
 }