diff --git a/ICSharpCode.Decompiler/IL/Instructions.cs b/ICSharpCode.Decompiler/IL/Instructions.cs
index cc14d1a5e..02aa1bddb 100644
--- a/ICSharpCode.Decompiler/IL/Instructions.cs
+++ b/ICSharpCode.Decompiler/IL/Instructions.cs
@@ -194,12 +194,12 @@ namespace ICSharpCode.Decompiler.IL
/// Load address of inline array element.
LdElemaInlineArray,
/// Retrieves a pinnable reference for the input object.
- /// The input must be an object reference (O).
+ /// The input must be an object reference (Obj).
/// If the input is an array/string, evaluates to a reference to the first element/character, or to a null reference if the array is null or empty.
/// Otherwise, uses the GetPinnableReference method to get the reference, or evaluates to a null reference if the input is null.
///
GetPinnableReference,
- /// Maps a string value to an integer. This is used in switch(string).
+ /// Maps a string value to an integer. This is used in switch(string).The input can be a `string` or a `ReadOnlySpan<char>`.
StringToInt,
/// ILAst representation of Expression.Convert.
ExpressionTreeCast,
@@ -1956,7 +1956,7 @@ namespace ICSharpCode.Decompiler.IL
internal override void CheckInvariant(ILPhase phase, ICompilation compilation)
{
base.CheckInvariant(phase, compilation);
- DebugAssert(onExpression.ResultType == StackType.Obj);
+ Debug.Assert(onExpression.ResultType == StackType.Obj);
}
}
}
@@ -2103,7 +2103,7 @@ namespace ICSharpCode.Decompiler.IL
base.CheckInvariant(phase, compilation);
DebugAssert(phase <= ILPhase.InILReader || this.IsDescendantOf(variable.Function!));
DebugAssert(phase <= ILPhase.InILReader || variable.Function!.Variables[variable.IndexInFunction] == variable);
- DebugAssert(resourceExpression.ResultType is StackType.Obj or StackType.VT);
+ Debug.Assert(resourceExpression.ResultType == StackType.Obj || resourceExpression.ResultType == StackType.VT);
}
}
}
@@ -3622,9 +3622,9 @@ namespace ICSharpCode.Decompiler.IL
internal override void CheckInvariant(ILPhase phase, ICompilation compilation)
{
base.CheckInvariant(phase, compilation);
- DebugAssert(destAddress.ResultType == StackType.I || destAddress.ResultType == StackType.Ref);
- DebugAssert(sourceAddress.ResultType == StackType.I || sourceAddress.ResultType == StackType.Ref);
- DebugAssert(size.ResultType == StackType.I4);
+ Debug.Assert(destAddress.ResultType == StackType.I || destAddress.ResultType == StackType.Ref);
+ Debug.Assert(sourceAddress.ResultType == StackType.I || sourceAddress.ResultType == StackType.Ref);
+ Debug.Assert(size.ResultType == StackType.I4);
}
}
}
@@ -3774,9 +3774,9 @@ namespace ICSharpCode.Decompiler.IL
internal override void CheckInvariant(ILPhase phase, ICompilation compilation)
{
base.CheckInvariant(phase, compilation);
- DebugAssert(address.ResultType == StackType.I || address.ResultType == StackType.Ref);
- DebugAssert(value.ResultType == StackType.I4);
- DebugAssert(size.ResultType == StackType.I4);
+ Debug.Assert(address.ResultType == StackType.I || address.ResultType == StackType.Ref);
+ Debug.Assert(value.ResultType == StackType.I4);
+ Debug.Assert(size.ResultType == StackType.I4);
}
}
}
@@ -4142,7 +4142,7 @@ namespace ICSharpCode.Decompiler.IL
internal override void CheckInvariant(ILPhase phase, ICompilation compilation)
{
base.CheckInvariant(phase, compilation);
- DebugAssert(target.ResultType == StackType.Ref || target.ResultType == StackType.I);
+ Debug.Assert(target.ResultType == StackType.Ref || target.ResultType == StackType.I);
}
}
}
@@ -4253,7 +4253,7 @@ namespace ICSharpCode.Decompiler.IL
internal override void CheckInvariant(ILPhase phase, ICompilation compilation)
{
base.CheckInvariant(phase, compilation);
- DebugAssert(target.ResultType == StackType.Ref || target.ResultType == StackType.I);
+ Debug.Assert(target.ResultType == StackType.Ref || target.ResultType == StackType.I);
}
}
}
@@ -4393,8 +4393,8 @@ namespace ICSharpCode.Decompiler.IL
internal override void CheckInvariant(ILPhase phase, ICompilation compilation)
{
base.CheckInvariant(phase, compilation);
- DebugAssert(target.ResultType == StackType.Ref || target.ResultType == StackType.I);
- DebugAssert(value.ResultType == type.GetStackType());
+ Debug.Assert(target.ResultType == StackType.Ref || target.ResultType == StackType.I);
+ Debug.Assert(value.ResultType == type.GetStackType());
CheckTargetSlot();
}
}
@@ -4928,7 +4928,7 @@ namespace ICSharpCode.Decompiler.IL
internal override void CheckInvariant(ILPhase phase, ICompilation compilation)
{
base.CheckInvariant(phase, compilation);
- DebugAssert(array.ResultType == StackType.Obj);
+ Debug.Assert(array.ResultType == StackType.Obj);
}
}
}
@@ -5185,7 +5185,7 @@ namespace ICSharpCode.Decompiler.IL
namespace ICSharpCode.Decompiler.IL
{
/// Retrieves a pinnable reference for the input object.
- /// The input must be an object reference (O).
+ /// The input must be an object reference (Obj).
/// If the input is an array/string, evaluates to a reference to the first element/character, or to a null reference if the array is null or empty.
/// Otherwise, uses the GetPinnableReference method to get the reference, or evaluates to a null reference if the input is null.
///
@@ -5302,13 +5302,13 @@ namespace ICSharpCode.Decompiler.IL
internal override void CheckInvariant(ILPhase phase, ICompilation compilation)
{
base.CheckInvariant(phase, compilation);
- DebugAssert(argument.ResultType == StackType.Obj);
+ Debug.Assert(argument.ResultType == StackType.Obj);
}
}
}
namespace ICSharpCode.Decompiler.IL
{
- /// Maps a string value to an integer. This is used in switch(string).
+ /// Maps a string value to an integer. This is used in switch(string).The input can be a `string` or a `ReadOnlySpan<char>`.
public sealed partial class StringToInt : ILInstruction
{
public static readonly SlotInfo ArgumentSlot = new SlotInfo("Argument", canInlineInto: true);
@@ -5392,7 +5392,7 @@ namespace ICSharpCode.Decompiler.IL
internal override void CheckInvariant(ILPhase phase, ICompilation compilation)
{
base.CheckInvariant(phase, compilation);
- DebugAssert(argument.ResultType == StackType.Obj);
+ Debug.Assert(argument.ResultType == StackType.Obj || argument.ResultType == StackType.VT);
}
}
}
@@ -5918,7 +5918,7 @@ namespace ICSharpCode.Decompiler.IL
internal override void CheckInvariant(ILPhase phase, ICompilation compilation)
{
base.CheckInvariant(phase, compilation);
- DebugAssert(argument.ResultType == StackType.Obj);
+ Debug.Assert(argument.ResultType == StackType.Obj);
}
}
}
@@ -6006,7 +6006,7 @@ namespace ICSharpCode.Decompiler.IL
internal override void CheckInvariant(ILPhase phase, ICompilation compilation)
{
base.CheckInvariant(phase, compilation);
- DebugAssert(target.ResultType == StackType.Obj);
+ Debug.Assert(target.ResultType == StackType.Obj);
}
}
}
@@ -6111,7 +6111,7 @@ namespace ICSharpCode.Decompiler.IL
internal override void CheckInvariant(ILPhase phase, ICompilation compilation)
{
base.CheckInvariant(phase, compilation);
- DebugAssert(target.ResultType == StackType.Obj);
+ Debug.Assert(target.ResultType == StackType.Obj);
}
}
}
@@ -6554,7 +6554,7 @@ namespace ICSharpCode.Decompiler.IL
internal override void CheckInvariant(ILPhase phase, ICompilation compilation)
{
base.CheckInvariant(phase, compilation);
- DebugAssert(argument.ResultType == StackType.Obj);
+ Debug.Assert(argument.ResultType == StackType.Obj);
}
}
}
diff --git a/ICSharpCode.Decompiler/IL/Instructions.tt b/ICSharpCode.Decompiler/IL/Instructions.tt
index 8a20bff22..db6041f6c 100644
--- a/ICSharpCode.Decompiler/IL/Instructions.tt
+++ b/ICSharpCode.Decompiler/IL/Instructions.tt
@@ -92,7 +92,7 @@
MatchCondition("Value.PerformMatch(o.Value, ref match)")),
new OpCode("dynamic.compound", "Common instruction for dynamic compound assignments.",
CustomClassName("DynamicCompoundAssign"), BaseClass("CompoundAssignmentInstruction"),
- MayThrow, SideEffect, CustomWriteTo, CustomConstructor, ResultType("SpecialType.Dynamic", "O"),
+ MayThrow, SideEffect, CustomWriteTo, CustomConstructor, ResultType("SpecialType.Dynamic", "Obj"),
MatchCondition("this.EvalMode == o.EvalMode"),
MatchCondition("this.TargetKind == o.TargetKind"),
MatchCondition("Target.PerformMatch(o.Target, ref match)"),
@@ -144,12 +144,12 @@
MatchCondition("faultBlock.PerformMatch(o.faultBlock, ref match)")),
new OpCode("lock", "Lock statement", CustomClassName("LockInstruction"),
CustomChildren(new [] {
- new ArgumentInfo("onExpression") { ExpectedTypes = new[] { "O" }},
+ new ArgumentInfo("onExpression") { ExpectedTypes = new[] { "Obj" }},
new ChildInfo("body")
}), CustomWriteTo, ControlFlow, SideEffect, VoidResult),
new OpCode("using", "Using statement", CustomClassName("UsingInstruction"), HasVariableOperand("Store"),
CustomChildren(new [] {
- new ArgumentInfo("resourceExpression") { ExpectedTypes = new[] { "O" }},
+ new ArgumentInfo("resourceExpression") { ExpectedTypes = new[] { "Obj", "VT" }},
new ChildInfo("body")
}), CustomWriteTo, ControlFlow, SideEffect, VoidResult),
new OpCode("debug.break", "Breakpoint instruction",
@@ -217,7 +217,7 @@
new OpCode("ldc.f8", "Loads a constant 64-bit floating-point number.",
LoadConstant("double"), ResultType("Double", "F8")),
new OpCode("ldc.decimal", "Loads a constant decimal.",
- LoadConstant("decimal"), ResultType("Decimal", "O")),
+ LoadConstant("decimal"), ResultType("Decimal", "VT")),
new OpCode("ldnull", "Loads the null reference.",
CustomClassName("LdNull"), NoArguments, ResultType("Object", "Obj")),
new OpCode("ldftn", "Load method pointer",
@@ -301,7 +301,7 @@
CustomClassName("SizeOf"), NoArguments, HasTypeOperand, ResultType("Int32", "I4")),
new OpCode("ldlen", "Returns the length of an array as 'native unsigned int'.",
- CustomClassName("LdLen"), CustomArguments(("array", new[] { "O" })), CustomConstructor, CustomWriteTo, MayThrow),
+ CustomClassName("LdLen"), CustomArguments(("array", new[] { "Obj" })), CustomConstructor, CustomWriteTo, MayThrow),
new OpCode("ldelema", "Load address of array element.",
CustomClassName("LdElema"), HasTypeOperand, CustomChildren(new [] { new ArgumentInfo("array"), new ArgumentInfo("indices") { IsCollection = true } }, true),
BoolFlag("WithSystemIndex"),
@@ -310,14 +310,15 @@
CustomClassName("LdElemaInlineArray"), HasTypeOperand, CustomChildren(new [] { new ArgumentInfo("array"), new ArgumentInfo("indices") { IsCollection = true } }, true),
MayThrow, ResultType("new ByReferenceType(this.Type)", "Ref"), SupportsReadonlyPrefix),
new OpCode("get.pinnable.reference", "Retrieves a pinnable reference for the input object." + Environment.NewLine
- + "The input must be an object reference (O)." + Environment.NewLine
+ + "The input must be an object reference (Obj)." + Environment.NewLine
+ "If the input is an array/string, evaluates to a reference to the first element/character, or to a null reference if the array is null or empty." + Environment.NewLine
+ "Otherwise, uses the GetPinnableReference method to get the reference, or evaluates to a null reference if the input is null." + Environment.NewLine,
- CustomArguments(("argument", new[] { "O" })),
+ CustomArguments(("argument", new[] { "Obj" })),
HasTypeOperand,
ResultType("new ByReferenceType(this.Type)", "Ref"), HasMethodOperand(nullable: true)),
- new OpCode("string.to.int", "Maps a string value to an integer. This is used in switch(string).",
- CustomArguments(("argument", new[] { "O" })), CustomConstructor, CustomWriteTo, ResultType("Int32", "I4")),
+ new OpCode("string.to.int", "Maps a string value to an integer. This is used in switch(string)."
+ + "The input can be a `string` or a `ReadOnlySpan<char>`.",
+ CustomArguments(("argument", new[] { "Obj", "VT" })), CustomConstructor, CustomWriteTo, ResultType("Int32", "I4")),
new OpCode("expression.tree.cast", "ILAst representation of Expression.Convert.",
CustomClassName("ExpressionTreeCast"), Unary, HasTypeOperand, MayThrow, CustomConstructor, CustomWriteTo,
@@ -347,11 +348,11 @@
new OpCode("dynamic.unary.operator", "ILAst representation of a unary operator inside a dynamic expression (maps to Binder.UnaryOperation).",
CustomClassName("DynamicUnaryOperatorInstruction"), Dynamic, CustomArguments(("operand", null)), CustomWriteTo),
new OpCode("dynamic.convert", "ILAst representation of a cast inside a dynamic expression (maps to Binder.Convert).",
- CustomClassName("DynamicConvertInstruction"), Dynamic, HasTypeOperand, CustomArguments(("argument", new[] { "O" })), CustomWriteTo),
+ CustomClassName("DynamicConvertInstruction"), Dynamic, HasTypeOperand, CustomArguments(("argument", new[] { "Obj" })), CustomWriteTo),
new OpCode("dynamic.getmember", "ILAst representation of a property get method call inside a dynamic expression (maps to Binder.GetMember).",
- CustomClassName("DynamicGetMemberInstruction"), Dynamic, CustomArguments(("target", new[] { "O" })), CustomConstructor, CustomWriteTo),
+ CustomClassName("DynamicGetMemberInstruction"), Dynamic, CustomArguments(("target", new[] { "Obj" })), CustomConstructor, CustomWriteTo),
new OpCode("dynamic.setmember", "ILAst representation of a property set method call inside a dynamic expression (maps to Binder.SetMember).",
- CustomClassName("DynamicSetMemberInstruction"), Dynamic, CustomArguments(("target", new[] { "O" }), ("value", null)), CustomWriteTo),
+ CustomClassName("DynamicSetMemberInstruction"), Dynamic, CustomArguments(("target", new[] { "Obj" }), ("value", null)), CustomWriteTo),
new OpCode("dynamic.getindex", "ILAst representation of an indexer get method call inside a dynamic expression (maps to Binder.GetIndex).",
CustomClassName("DynamicGetIndexInstruction"), Dynamic, CustomChildren(new []{ new ArgumentInfo("arguments") { IsCollection = true }}), CustomWriteTo),
new OpCode("dynamic.setindex", "ILAst representation of an indexer set method call inside a dynamic expression (maps to Binder.SetIndex).",
@@ -363,7 +364,7 @@
new OpCode("dynamic.invoke", "ILAst representation of a delegate invocation inside a dynamic expression (maps to Binder.Invoke).",
CustomClassName("DynamicInvokeInstruction"), Dynamic, CustomChildren(new []{ new ArgumentInfo("arguments") { IsCollection = true }}), CustomWriteTo),
new OpCode("dynamic.isevent", "ILAst representation of a call to the Binder.IsEvent method inside a dynamic expression.",
- CustomClassName("DynamicIsEventInstruction"), Dynamic, CustomArguments(("argument", new[] { "O" })), CustomWriteTo),
+ CustomClassName("DynamicIsEventInstruction"), Dynamic, CustomArguments(("argument", new[] { "Obj" })), CustomWriteTo),
new OpCode("match", "ILAst representation of C# patterns",
CustomClassName("MatchInstruction"), HasVariableOperand("Store"), HasMethodOperand(nullable: true),
@@ -925,7 +926,7 @@ namespace ICSharpCode.Decompiler.IL
checkString += " || ";
checkString += arg + ".ResultType == " + expectedTypeCode;
}
- opCode.Invariants.Add("DebugAssert(" + checkString + ");");
+ opCode.Invariants.Add("Debug.Assert(" + checkString + ");");
}
}
opCode.WriteArguments.Add("output.Write(')');");