private type_node InstantiateParameter(SemanticTree.ITypeNode genericType, type_node[] instances) { if (genericType.is_generic_parameter) { return(instances[(genericType as type_node).generic_param_index]); } else { var genericNode = (genericType as generic_instance_type_node); if (genericNode != null) { var parameters = genericNode.instance_params.Select(x => InstantiateParameter(x, instances)).ToList(); genericNode.instance_params = parameters; } return(genericNode as type_node); } }
private IEnumerable <int> GenericParameterIndices(SemanticTree.ITypeNode node) { if (node.is_generic_parameter) { yield return((node as type_node).generic_param_index); } if (node is generic_instance_type_node genericNode) { foreach (var index in genericNode.instance_params.Aggregate( Enumerable.Empty <int>(), (indices, nextNode) => indices.Concat(GenericParameterIndices(nextNode))) .Distinct()) { yield return(index); } } yield break; }