예제 #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);
 }