|
|
|
@ -2080,53 +2080,70 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
@@ -2080,53 +2080,70 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override object TrackedVisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) |
|
|
|
|
{ |
|
|
|
|
outputFormatter.PrintText(ToVBNetString(primitiveExpression)); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal static string ToVBNetString(PrimitiveExpression primitiveExpression) |
|
|
|
|
{ |
|
|
|
|
object val = primitiveExpression.Value; |
|
|
|
|
if (val == null) { |
|
|
|
|
outputFormatter.PrintToken(Tokens.Nothing); |
|
|
|
|
return null; |
|
|
|
|
return "Nothing"; |
|
|
|
|
} |
|
|
|
|
if (val is bool) { |
|
|
|
|
if ((bool)primitiveExpression.Value) { |
|
|
|
|
outputFormatter.PrintToken(Tokens.True); |
|
|
|
|
return "True"; |
|
|
|
|
} else { |
|
|
|
|
outputFormatter.PrintToken(Tokens.False); |
|
|
|
|
return "False"; |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (val is string) { |
|
|
|
|
outputFormatter.PrintText(ConvertString((string)val)); |
|
|
|
|
return null; |
|
|
|
|
return ConvertString((string)val); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (val is char) { |
|
|
|
|
outputFormatter.PrintText(ConvertCharLiteral((char)primitiveExpression.Value)); |
|
|
|
|
return null; |
|
|
|
|
return ConvertCharLiteral((char)primitiveExpression.Value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (val is decimal) { |
|
|
|
|
outputFormatter.PrintText(((decimal)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "D"); |
|
|
|
|
return null; |
|
|
|
|
return ((decimal)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "D"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (val is float) { |
|
|
|
|
outputFormatter.PrintText(((float)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "F"); |
|
|
|
|
return null; |
|
|
|
|
return ((float)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "F"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (val is double) { |
|
|
|
|
string text = ((double)val).ToString(NumberFormatInfo.InvariantInfo); |
|
|
|
|
if (text.IndexOf('.') < 0 && text.IndexOf('E') < 0) |
|
|
|
|
return text + ".0"; |
|
|
|
|
else |
|
|
|
|
return text; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (val is IFormattable) { |
|
|
|
|
StringBuilder b = new StringBuilder(); |
|
|
|
|
if (primitiveExpression.LiteralFormat == LiteralFormat.HexadecimalNumber) { |
|
|
|
|
outputFormatter.PrintText("&H"); |
|
|
|
|
outputFormatter.PrintText(((IFormattable)val).ToString("x", NumberFormatInfo.InvariantInfo)); |
|
|
|
|
b.Append("&H"); |
|
|
|
|
b.Append(((IFormattable)val).ToString("x", NumberFormatInfo.InvariantInfo)); |
|
|
|
|
} else { |
|
|
|
|
outputFormatter.PrintText(((IFormattable)val).ToString(null, NumberFormatInfo.InvariantInfo)); |
|
|
|
|
b.Append(((IFormattable)val).ToString(null, NumberFormatInfo.InvariantInfo)); |
|
|
|
|
} |
|
|
|
|
if (val is ushort || val is uint || val is ulong) { |
|
|
|
|
b.Append('U'); |
|
|
|
|
if (val is uint) |
|
|
|
|
b.Append('I'); |
|
|
|
|
} |
|
|
|
|
if (val is long || val is ulong) |
|
|
|
|
b.Append('L'); |
|
|
|
|
if (val is short || val is ushort) |
|
|
|
|
b.Append('S'); |
|
|
|
|
return b.ToString(); |
|
|
|
|
} else { |
|
|
|
|
outputFormatter.PrintText(val.ToString()); |
|
|
|
|
return val.ToString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override object TrackedVisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data) |
|
|
|
@ -2348,12 +2365,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
@@ -2348,12 +2365,18 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
|
|
|
|
|
|
|
|
|
|
case UnaryOperatorType.Dereference: |
|
|
|
|
outputFormatter.PrintToken(Tokens.Times); |
|
|
|
|
TrackedVisit(unaryOperatorExpression.Expression, data); |
|
|
|
|
return null; |
|
|
|
|
case UnaryOperatorType.AddressOf: |
|
|
|
|
outputFormatter.PrintToken(Tokens.AddressOf); |
|
|
|
|
TrackedVisit(unaryOperatorExpression.Expression, data); |
|
|
|
|
return null; |
|
|
|
|
default: |
|
|
|
|
Error("unknown unary operator: " + unaryOperatorExpression.Op.ToString(), unaryOperatorExpression.StartLocation); |
|
|
|
|
outputFormatter.PrintText(unaryOperatorExpression.Op.ToString()); |
|
|
|
|
outputFormatter.PrintText("("); |
|
|
|
|
TrackedVisit(unaryOperatorExpression.Expression, data); |
|
|
|
|
outputFormatter.PrintText(")"); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -2422,32 +2445,27 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
@@ -2422,32 +2445,27 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
|
|
|
|
|
|
|
|
|
|
public override object TrackedVisitSizeOfExpression(SizeOfExpression sizeOfExpression, object data) |
|
|
|
|
{ |
|
|
|
|
if (!sizeOfExpression.TypeReference.IsArrayType) { |
|
|
|
|
if (sizeOfExpression.TypeReference.PointerNestingLevel != 0) { |
|
|
|
|
outputFormatter.PrintText("IntPtr.Size"); |
|
|
|
|
return null; |
|
|
|
|
} else { |
|
|
|
|
switch (sizeOfExpression.TypeReference.Type) { |
|
|
|
|
case "System.Byte": |
|
|
|
|
case "System.SByte": |
|
|
|
|
outputFormatter.PrintText("1"); |
|
|
|
|
return null; |
|
|
|
|
case "System.Char": |
|
|
|
|
case "System.Int16": |
|
|
|
|
case "System.UInt16": |
|
|
|
|
outputFormatter.PrintText("2"); |
|
|
|
|
return null; |
|
|
|
|
case "System.Single": |
|
|
|
|
case "System.Int32": |
|
|
|
|
case "System.UInt32": |
|
|
|
|
outputFormatter.PrintText("4"); |
|
|
|
|
return null; |
|
|
|
|
case "System.Double": |
|
|
|
|
case "System.Int64": |
|
|
|
|
case "System.UInt64": |
|
|
|
|
outputFormatter.PrintText("8"); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
if (!sizeOfExpression.TypeReference.IsArrayType && sizeOfExpression.TypeReference.PointerNestingLevel == 0) { |
|
|
|
|
switch (sizeOfExpression.TypeReference.Type) { |
|
|
|
|
case "System.Byte": |
|
|
|
|
case "System.SByte": |
|
|
|
|
outputFormatter.PrintText("1"); |
|
|
|
|
return null; |
|
|
|
|
case "System.Char": |
|
|
|
|
case "System.Int16": |
|
|
|
|
case "System.UInt16": |
|
|
|
|
outputFormatter.PrintText("2"); |
|
|
|
|
return null; |
|
|
|
|
case "System.Single": |
|
|
|
|
case "System.Int32": |
|
|
|
|
case "System.UInt32": |
|
|
|
|
outputFormatter.PrintText("4"); |
|
|
|
|
return null; |
|
|
|
|
case "System.Double": |
|
|
|
|
case "System.Int64": |
|
|
|
|
case "System.UInt64": |
|
|
|
|
outputFormatter.PrintText("8"); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
UnsupportedNode(sizeOfExpression); |
|
|
|
|