Skip to end of metadata
Go to start of metadata

The ProcessMethodBodies step does a tremendous amount of work.

  • One of the things it does is handle when you set properties by passing them to the constructor, using the builtin __eval__ function.
  • Also adding an event handler (Click += OnClick) is transformed into a method call (add_Click(OnClick)).
  • Closures are duplicated into a regular method. These are processed more in later steps.

See this example:

import System.Windows.Forms from System.Windows.Forms

[Boo.Lang.ModuleAttribute]
public final transient class TempModule(System.Object):

	private static def Main(argv as (string)) as System.Void:
		f = Form()
		clickcount = 0
		b = Button(Text: 'Hello', Dock: DockStyle.Fill)
		b.Click += { print("you clicked me ${(++clickcount)} times") }
		f.Controls.Add(b)
		f.ShowDialog()

	private def constructor():
		pass

is transformed into:

import System.Windows.Forms from System.Windows.Forms

[Boo.Lang.ModuleAttribute]
public final transient class TempModule(System.Object):

	private static def Main(argv as (System.String)) as System.Void:
		f = System.Windows.Forms.Form()
		clickcount = 0
		b = __eval__(
                     (___temp1 = System.Windows.Forms.Button()), 
                      ___temp1.set_Text('Hello'), 
                      ___temp1.set_Dock(System.Windows.Forms.DockStyle.Fill), 
                      ___temp1)
		b.add_Click(
                 { Boo.Lang.Builtins.print("you clicked me ${(clickcount = (clickcount + 1))} times") })
		f.get_Controls().Add(b)
		f.ShowDialog()

	private def constructor():
		super()

	internal static def ___closure2() as System.Void:
		Boo.Lang.Builtins.print(
                  "you clicked me ${(clickcount = (clickcount + 1))} times")
  • No labels