Browse Source

Ldelema;

Instance method calls
pull/1/head^2
David Srbecký 18 years ago
parent
commit
e650e1afe6
  1. 12
      src/AstMetodBodyBuilder.cs

12
src/AstMetodBodyBuilder.cs

@ -21,7 +21,7 @@ namespace Decompiler
foreach(Instruction instr in methodDef.Body.Instructions) { foreach(Instruction instr in methodDef.Body.Instructions) {
OpCode opCode = instr.OpCode; OpCode opCode = instr.OpCode;
string description = string description =
string.Format("/* IL_{0:X2}: {1, -22} # {2}->{3} {4} {5} */", string.Format("/* {1, -22} # {2}->{3} {4} {5} */",
instr.Offset, instr.Offset,
opCode + " " + FormatInstructionOperand(instr.Operand), opCode + " " + FormatInstructionOperand(instr.Operand),
opCode.StackBehaviourPop, opCode.StackBehaviourPop,
@ -129,7 +129,7 @@ namespace Decompiler
case Code.Ldelem_R8: case Code.Ldelem_R8:
case Code.Ldelem_Ref: return new Ast.IndexerExpression(arg1, new List<Expression>(new Expression[] {arg2})); case Code.Ldelem_Ref: return new Ast.IndexerExpression(arg1, new List<Expression>(new Expression[] {arg2}));
case Code.Ldelem_Any: throw new NotImplementedException(); case Code.Ldelem_Any: throw new NotImplementedException();
case Code.Ldelema: throw new NotImplementedException(); case Code.Ldelema: return new Ast.IndexerExpression(arg1, new List<Expression>(new Expression[] {arg2}));
case Code.Stelem_I: case Code.Stelem_I:
case Code.Stelem_I1: case Code.Stelem_I1:
@ -230,9 +230,13 @@ namespace Decompiler
Ast.IdentifierExpression astType = new Ast.IdentifierExpression(cecilMethod.DeclaringType.FullName); Ast.IdentifierExpression astType = new Ast.IdentifierExpression(cecilMethod.DeclaringType.FullName);
List<Ast.Expression> astArgs = new List<Ast.Expression>(); List<Ast.Expression> astArgs = new List<Ast.Expression>();
for(int i = 0; i < cecilMethod.Parameters.Count; i++) { for(int i = 0; i < cecilMethod.Parameters.Count; i++) {
astArgs.Add(new Ast.IdentifierExpression("arg" + i)); astArgs.Add(new Ast.IdentifierExpression("arg" + (cecilMethod.HasThis ? i + 1 : i)));
}
if (cecilMethod.HasThis) {
return new Ast.InvocationExpression(new Ast.MemberReferenceExpression(arg1, cecilMethod.Name), astArgs);
} else {
return new Ast.InvocationExpression(new Ast.MemberReferenceExpression(astType, cecilMethod.Name), astArgs);
} }
return new Ast.InvocationExpression(new Ast.MemberReferenceExpression(astType, cecilMethod.Name), astArgs);
case Code.Calli: throw new NotImplementedException(); case Code.Calli: throw new NotImplementedException();
case Code.Callvirt: throw new NotImplementedException(); case Code.Callvirt: throw new NotImplementedException();
case Code.Castclass: throw new NotImplementedException(); case Code.Castclass: throw new NotImplementedException();

Loading…
Cancel
Save