internal static int GetNumElements(this TypeSymbol type)
{
switch (type.Kind)
{
case SymbolKind.Array:
{
var arrayType = (ArraySymbol) type;
return arrayType.Dimension ?? 0;
}
case SymbolKind.IntrinsicMatrixType:
{
var matrixType = (IntrinsicMatrixTypeSymbol) type;
return matrixType.Rows * matrixType.Cols;
}
case SymbolKind.IntrinsicScalarType:
{
return 1;
}
case SymbolKind.IntrinsicVectorType:
{
var vectorType = (IntrinsicVectorTypeSymbol) type;
return vectorType.NumComponents;
}
default:
{
return 1;
}
}
}