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); }
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); }
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); } }
public AstParameterReference(AstParameterDefinition parameter) { Argument.RequireNotNull("parameter", parameter); Parameter = parameter; }
protected virtual void AppendParameterDefinition(StringBuilder builder, AstParameterDefinition parameterDefinition) { builder.Append(parameterDefinition); }