Browse Source

Property access. (Detect properties by naming convention; still needs to be done properly)

pull/1/head^2
David Srbecký 18 years ago
parent
commit
6e7f51fad7
  1. 100
      bin/Debug/output.cs
  2. 23
      src/AstMetodBodyBuilder.cs

100
bin/Debug/output.cs

@ -32,56 +32,56 @@ namespace Reversi @@ -32,56 +32,56 @@ namespace Reversi
@this.okButton = (IL__newobj(.ctor()));
@this.copyrightLabel = (IL__newobj(.ctor()));
@this.SuspendLayout();
(@this.iconPictureBox).set_Location((IL__newobj(.ctor(), 77, 56)));
(@this.iconPictureBox).set_Name("iconPictureBox");
(@this.iconPictureBox).set_Size((IL__newobj(.ctor(), 96, 96)));
(@this.iconPictureBox).set_TabIndex(0);
(@this.iconPictureBox).set_TabStop(0);
(@this.titleLabel).set_AutoSize(1);
(@this.titleLabel).set_Font((IL__newobj(.ctor(), "Microsoft Sans Serif", 8.25f, 1, 3, 0)));
(@this.titleLabel).set_Location((IL__newobj(.ctor(), 103, 16)));
(@this.titleLabel).set_Name("titleLabel");
(@this.titleLabel).set_Size((IL__newobj(.ctor(), 44, 16)));
(@this.titleLabel).set_TabIndex(0);
(@this.titleLabel).set_Text("Reversi");
(@this.titleLabel).set_TextAlign(32);
(@this.versionLabel).set_AutoSize(1);
(@this.versionLabel).set_Location((IL__newobj(.ctor(), 95, 32)));
(@this.versionLabel).set_Name("versionLabel");
(@this.versionLabel).set_Size((IL__newobj(.ctor(), 61, 16)));
(@this.versionLabel).set_TabIndex(1);
(@this.versionLabel).set_Text("Version 2.0");
(@this.versionLabel).set_TextAlign(32);
(@this.okButton).set_DialogResult(1);
(@this.okButton).set_Location((IL__newobj(.ctor(), 88, 192)));
(@this.okButton).set_Name("okButton");
(@this.okButton).set_TabIndex(3);
(@this.okButton).set_Text("OK");
(@this.copyrightLabel).set_AutoSize(1);
(@this.copyrightLabel).set_Location((IL__newobj(.ctor(), 36, 160)));
(@this.copyrightLabel).set_Name("copyrightLabel");
(@this.copyrightLabel).set_Size((IL__newobj(.ctor(), 178, 16)));
(@this.copyrightLabel).set_TabIndex(2);
(@this.copyrightLabel).set_Text("Copyright 2003-2005 by Mike Hall.");
(@this.copyrightLabel).set_TextAlign(32);
@this.set_AcceptButton((@this.okButton));
@this.set_AutoScaleBaseSize((IL__newobj(.ctor(), 5, 13)));
@this.set_CancelButton((@this.okButton));
@this.set_ClientSize((IL__newobj(.ctor(), 250, 224)));
@this.set_ControlBox(0);
@this.get_Controls().Add((@this.copyrightLabel));
@this.get_Controls().Add((@this.versionLabel));
@this.get_Controls().Add((@this.titleLabel));
@this.get_Controls().Add((@this.okButton));
@this.get_Controls().Add((@this.iconPictureBox));
@this.set_FormBorderStyle(3);
@this.set_Icon((IL__castclass(System.Drawing.Icon, (V_0.GetObject("$this.Icon")))));
@this.set_MaximizeBox(0);
@this.set_MinimizeBox(0);
@this.set_Name("AboutDialog");
@this.set_ShowInTaskbar(0);
@this.set_StartPosition(4);
@this.set_Text("About Reversi");
(@this.iconPictureBox).Location = (IL__newobj(.ctor(), 77, 56));
(@this.iconPictureBox).Name = "iconPictureBox";
(@this.iconPictureBox).Size = (IL__newobj(.ctor(), 96, 96));
(@this.iconPictureBox).TabIndex = 0;
(@this.iconPictureBox).TabStop = 0;
(@this.titleLabel).AutoSize = 1;
(@this.titleLabel).Font = (IL__newobj(.ctor(), "Microsoft Sans Serif", 8.25f, 1, 3, 0));
(@this.titleLabel).Location = (IL__newobj(.ctor(), 103, 16));
(@this.titleLabel).Name = "titleLabel";
(@this.titleLabel).Size = (IL__newobj(.ctor(), 44, 16));
(@this.titleLabel).TabIndex = 0;
(@this.titleLabel).Text = "Reversi";
(@this.titleLabel).TextAlign = 32;
(@this.versionLabel).AutoSize = 1;
(@this.versionLabel).Location = (IL__newobj(.ctor(), 95, 32));
(@this.versionLabel).Name = "versionLabel";
(@this.versionLabel).Size = (IL__newobj(.ctor(), 61, 16));
(@this.versionLabel).TabIndex = 1;
(@this.versionLabel).Text = "Version 2.0";
(@this.versionLabel).TextAlign = 32;
(@this.okButton).DialogResult = 1;
(@this.okButton).Location = (IL__newobj(.ctor(), 88, 192));
(@this.okButton).Name = "okButton";
(@this.okButton).TabIndex = 3;
(@this.okButton).Text = "OK";
(@this.copyrightLabel).AutoSize = 1;
(@this.copyrightLabel).Location = (IL__newobj(.ctor(), 36, 160));
(@this.copyrightLabel).Name = "copyrightLabel";
(@this.copyrightLabel).Size = (IL__newobj(.ctor(), 178, 16));
(@this.copyrightLabel).TabIndex = 2;
(@this.copyrightLabel).Text = "Copyright 2003-2005 by Mike Hall.";
(@this.copyrightLabel).TextAlign = 32;
@this.AcceptButton = (@this.okButton);
@this.AutoScaleBaseSize = (IL__newobj(.ctor(), 5, 13));
@this.CancelButton = (@this.okButton);
@this.ClientSize = (IL__newobj(.ctor(), 250, 224));
@this.ControlBox = 0;
@this.Controls.Add((@this.copyrightLabel));
@this.Controls.Add((@this.versionLabel));
@this.Controls.Add((@this.titleLabel));
@this.Controls.Add((@this.okButton));
@this.Controls.Add((@this.iconPictureBox));
@this.FormBorderStyle = 3;
@this.Icon = (IL__castclass(System.Drawing.Icon, (V_0.GetObject("$this.Icon"))));
@this.MaximizeBox = 0;
@this.MinimizeBox = 0;
@this.Name = "AboutDialog";
@this.ShowInTaskbar = 0;
@this.StartPosition = 4;
@this.Text = "About Reversi";
@this.ResumeLayout(0);
}
}

23
src/AstMetodBodyBuilder.cs

@ -382,13 +382,28 @@ namespace Decompiler @@ -382,13 +382,28 @@ namespace Decompiler
case Code.Callvirt:
// TODO: Diferentiate vitual and non-vitual dispach
Cecil.MethodReference cecilMethod = ((MethodReference)operand);
Ast.IdentifierExpression astType = new Ast.IdentifierExpression(cecilMethod.DeclaringType.FullName);
Ast.Expression target;
List<Ast.Expression> methodArgs = new List<Ast.Expression>(args);
if (cecilMethod.HasThis) {
methodArgs.RemoveAt(0); // Remove 'this'
return new Ast.InvocationExpression(new Ast.MemberReferenceExpression(arg1, cecilMethod.Name), methodArgs);
target = methodArgs[0];
methodArgs.RemoveAt(0);
} else {
return new Ast.InvocationExpression(new Ast.MemberReferenceExpression(astType, cecilMethod.Name), methodArgs);
target = new Ast.IdentifierExpression(cecilMethod.DeclaringType.FullName);
}
// TODO: Hack, detect properties properly
if (cecilMethod.Name.StartsWith("get_")) {
return new Ast.MemberReferenceExpression(target, cecilMethod.Name.Remove(0, 4));
} else if (cecilMethod.Name.StartsWith("set_")) {
return new Ast.AssignmentExpression(
new Ast.MemberReferenceExpression(target, cecilMethod.Name.Remove(0, 4)),
AssignmentOperatorType.Assign,
methodArgs[0]
);
} else {
return new Ast.InvocationExpression(
new Ast.MemberReferenceExpression(target, cecilMethod.Name),
methodArgs
);
}
case Code.Calli: throw new NotImplementedException();
case Code.Castclass: throw new NotImplementedException();

Loading…
Cancel
Save