Browse Source

remove InitObj - replace with Void(StObj(DefaultValue))

pull/728/head
Siegfried Pammer 11 years ago
parent
commit
dbadabfb2a
  1. 7
      ICSharpCode.Decompiler/IL/ILReader.cs
  2. 41
      ICSharpCode.Decompiler/IL/Instructions.cs
  3. 2
      ICSharpCode.Decompiler/IL/Instructions.tt

7
ICSharpCode.Decompiler/IL/ILReader.cs

@ -597,7 +597,7 @@ namespace ICSharpCode.Decompiler.IL @@ -597,7 +597,7 @@ namespace ICSharpCode.Decompiler.IL
return new Void(new StObj(Pop(), ld, type));
}
case ILOpCode.Initobj:
return new InitObj(Pop(), ReadAndDecodeTypeReference());
return InitObj(Pop(), ReadAndDecodeTypeReference());
case ILOpCode.Isinst:
return new IsInst(Pop(), ReadAndDecodeTypeReference());
case ILOpCode.Ldelem:
@ -761,6 +761,11 @@ namespace ICSharpCode.Decompiler.IL @@ -761,6 +761,11 @@ namespace ICSharpCode.Decompiler.IL
return new Void(new StObj(new LdElema(array, index, type), value, type));
}
ILInstruction InitObj(ILInstruction target, IType type)
{
return new Void(new StObj(target, new DefaultValue(type), type));
}
private ILInstruction DecodeConstrainedCall()
{
var typeRef = ReadAndDecodeTypeReference();

41
ICSharpCode.Decompiler/IL/Instructions.cs

@ -164,8 +164,6 @@ namespace ICSharpCode.Decompiler.IL @@ -164,8 +164,6 @@ namespace ICSharpCode.Decompiler.IL
NewObj,
/// <summary>Creates an array instance.</summary>
NewArr,
/// <summary>Initializes the value at an address.</summary>
InitObj,
/// <summary>Returns the default value for a type.</summary>
DefaultValue,
/// <summary>Throws an exception.</summary>
@ -2472,36 +2470,6 @@ namespace ICSharpCode.Decompiler.IL @@ -2472,36 +2470,6 @@ namespace ICSharpCode.Decompiler.IL
}
}
/// <summary>Initializes the value at an address.</summary>
public sealed partial class InitObj : UnaryInstruction
{
public InitObj(ILInstruction argument, IType type) : base(OpCode.InitObj, argument)
{
this.type = type;
}
readonly IType type;
/// <summary>Returns the type operand.</summary>
public IType Type { get { return type; } }
public override StackType ResultType { get { return StackType.Void; } }
public override void WriteTo(ITextOutput output)
{
output.Write(OpCode);
output.Write(' ');
Disassembler.DisassemblerHelpers.WriteOperand(output, type);
output.Write('(');
Argument.WriteTo(output);
output.Write(')');
}
public override void AcceptVisitor(ILVisitor visitor)
{
visitor.VisitInitObj(this);
}
public override T AcceptVisitor<T>(ILVisitor<T> visitor)
{
return visitor.VisitInitObj(this);
}
}
/// <summary>Returns the default value for a type.</summary>
public sealed partial class DefaultValue : SimpleInstruction
{
@ -3058,10 +3026,6 @@ namespace ICSharpCode.Decompiler.IL @@ -3058,10 +3026,6 @@ namespace ICSharpCode.Decompiler.IL
{
Default(inst);
}
protected internal virtual void VisitInitObj(InitObj inst)
{
Default(inst);
}
protected internal virtual void VisitDefaultValue(DefaultValue inst)
{
Default(inst);
@ -3368,10 +3332,6 @@ namespace ICSharpCode.Decompiler.IL @@ -3368,10 +3332,6 @@ namespace ICSharpCode.Decompiler.IL
{
return Default(inst);
}
protected internal virtual T VisitInitObj(InitObj inst)
{
return Default(inst);
}
protected internal virtual T VisitDefaultValue(DefaultValue inst)
{
return Default(inst);
@ -3521,7 +3481,6 @@ namespace ICSharpCode.Decompiler.IL @@ -3521,7 +3481,6 @@ namespace ICSharpCode.Decompiler.IL
"unbox.any",
"newobj",
"newarr",
"initobj",
"default.value",
"throw",
"rethrow",

2
ICSharpCode.Decompiler/IL/Instructions.tt

@ -177,8 +177,6 @@ @@ -177,8 +177,6 @@
CustomClassName("NewObj"), Call, ResultType("Method.DeclaringType.GetStackType()")),
new OpCode("newarr", "Creates an array instance.",
CustomClassName("NewArr"), HasTypeOperand, CustomArguments("size"), MayThrow, ResultType("O")),
new OpCode("initobj", "Initializes the value at an address.",
CustomClassName("InitObj"), Unary, HasTypeOperand, VoidResult),
new OpCode("default.value", "Returns the default value for a type.",
NoArguments, HasTypeOperand, ResultType("type.GetStackType()")),
new OpCode("throw", "Throws an exception.",

Loading…
Cancel
Save