示例#1
0
        protected override void AppendParameterDefinition(StringBuilder builder, AstParameterDefinition parameter)
        {
            var length = builder.Length;

            Append(builder, parameter.Type);
            if (builder.Length > length)
            {
                builder.Append(" ");
            }

            builder.Append(parameter.Name);
        }
示例#2
0
        private IAstTypeReference InferType(AstParameterDefinition parameter, IAstFunctionDefinition function, ref int genericIndex)
        {
            var types = new HashSet <IAstTypeReference>();

            CollectTypesFromUsages(function, parameter, types);

            if (types.Count == 1)
            {
                return(types.Single());
            }

            var placeholder = new AstGenericPlaceholderType("T" + genericIndex, p => types);

            genericIndex += 1;
            return(placeholder);
        }
示例#3
0
        private void CollectTypesFromUsages(IAstElement parent, AstParameterDefinition parameter, ISet <IAstTypeReference> collectedTypes)
        {
            foreach (var child in parent.Children())
            {
                var reference = child as AstParameterReference;
                if (reference != null && reference.Parameter == parameter)
                {
                    var type = GetTypeFromUsage(parent, reference);
                    if (type != null)
                    {
                        collectedTypes.Add(type);
                    }

                    continue;
                }

                CollectTypesFromUsages(child, parameter, collectedTypes);
            }
        }
示例#4
0
 public AstParameterReference(AstParameterDefinition parameter)
 {
     Argument.RequireNotNull("parameter", parameter);
     Parameter = parameter;
 }
示例#5
0
 protected virtual void AppendParameterDefinition(StringBuilder builder, AstParameterDefinition parameterDefinition)
 {
     builder.Append(parameterDefinition);
 }