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

23
src/AstMetodBodyBuilder.cs

@ -382,13 +382,28 @@ namespace Decompiler
case Code.Callvirt: case Code.Callvirt:
// TODO: Diferentiate vitual and non-vitual dispach // TODO: Diferentiate vitual and non-vitual dispach
Cecil.MethodReference cecilMethod = ((MethodReference)operand); 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); List<Ast.Expression> methodArgs = new List<Ast.Expression>(args);
if (cecilMethod.HasThis) { if (cecilMethod.HasThis) {
methodArgs.RemoveAt(0); // Remove 'this' target = methodArgs[0];
return new Ast.InvocationExpression(new Ast.MemberReferenceExpression(arg1, cecilMethod.Name), methodArgs); methodArgs.RemoveAt(0);
} else { } 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.Calli: throw new NotImplementedException();
case Code.Castclass: throw new NotImplementedException(); case Code.Castclass: throw new NotImplementedException();

Loading…
Cancel
Save