public override void VisitVariableDeclaration(VariableDeclarationSyntax node)
{
// start with variable type
if (node.Type.IsVar)
{
// no idea
cb.AppendWithIndent("auto ");
}
else
{
var si = model.GetSymbolInfo(node.Type);
ITypeSymbol ts = (ITypeSymbol) si.Symbol;
if (ts != null)
cb.AppendWithIndent(ts.ToCppType()).Append(" ");
else
{
var n = node.Type as IdentifierNameSyntax;
if (n != null)
{
cb.AppendWithIndent(n.Identifier.Text).Append(" ");
}
}
}
// now comes the name(s)
for (int i = 0; i < node.Variables.Count; ++i)
{
var v = node.Variables[i];
cb.Append(v.Identifier.Text);
if (v.Initializer != null)
{
cb.Append(" = ");
v.Initializer.Accept(this);
}
cb.AppendLine(i + 1 == node.Variables.Count ? ";" : ",");
}
}