C# Class Fanx.Emit.FMethodEmit

FMethodEmit is used to emit IL methods from fcode methods. It encapsulates lot of nitty details like when to include an implicit self paramater, etc.
ファイルを表示 Open project: xored/f4

Public Methods

Method Description
FMethodEmit ( FTypeEmit emit ) : System.Collections

Constructor.

FMethodEmit ( FTypeEmit emit, FMethod method ) : System.Collections

Constructor.

emitCtor ( ) : void

Emit a constructor - constructors get created as a static factory methods, so that that CallNew can just push args and invoke them fan: class Foo { new make(Long a) { ... } } .net: static Foo make(Long a) { return make_(new Foo(), a) } static Foo make_(Foo self, Long a) { ... return self } We call the first method "make" the "factory" and the second method "make_" the "body". CallNew opcodes are routed to the ctor factory, and CallCtor opcodes are routed to the ctor body.

emitInterfaceRouter ( Type implType, Method m ) : void

The CLR requires all methods implemented by an interface to be marked as virtual. However, Fantom (and Java) allow this: mixin Mixin { abstract Long foo() } class Base { Long foo() { return 5 } } class Child : Base, Mixin { // don't need to implement foo() since Base defined it } So to work correctly in the CLR we need to trap this case and emit a virtual router method on child to satisfy the interface requirement: class Child : Base, Mixin { public virtual Long foo() { return base.foo(); } } TODO - optimize the intra-pod case

emitMixinBody ( ) : void
emitMixinInterface ( ) : void

Emit the method as a mixin interface

emitMixinRouter ( Method m ) : void

Emit a mixin router from a class to the mixin body methods.

emitNative ( ) : void
emitStandard ( ) : void

Emit a standard instance/static class method.

Protected Methods

Method Description
doEmit ( ) : PERWAPI.CILInstructions

This is the method that all the public emitX methods route to once everything is setup correctly.

Private Methods

Method Description
doEmit ( string localNames, string localTypes ) : PERWAPI.CILInstructions
emitWrapper ( PERWAPI main, int paramLen ) : void

Emit wrapper.

emitWrappers ( ) : void

Emit wrappers.

pushArgs ( PERWAPI code, bool self, int count ) : void

Push the specified number of arguments onto the stack.

Method Details

FMethodEmit() public method

Constructor.
public FMethodEmit ( FTypeEmit emit ) : System.Collections
emit FTypeEmit
return System.Collections

FMethodEmit() public method

Constructor.
public FMethodEmit ( FTypeEmit emit, FMethod method ) : System.Collections
emit FTypeEmit
method Fanx.Fcode.FMethod
return System.Collections

doEmit() protected method

This is the method that all the public emitX methods route to once everything is setup correctly.
protected doEmit ( ) : PERWAPI.CILInstructions
return PERWAPI.CILInstructions

emitCtor() public method

Emit a constructor - constructors get created as a static factory methods, so that that CallNew can just push args and invoke them fan: class Foo { new make(Long a) { ... } } .net: static Foo make(Long a) { return make_(new Foo(), a) } static Foo make_(Foo self, Long a) { ... return self } We call the first method "make" the "factory" and the second method "make_" the "body". CallNew opcodes are routed to the ctor factory, and CallCtor opcodes are routed to the ctor body.
public emitCtor ( ) : void
return void

emitInterfaceRouter() public method

The CLR requires all methods implemented by an interface to be marked as virtual. However, Fantom (and Java) allow this: mixin Mixin { abstract Long foo() } class Base { Long foo() { return 5 } } class Child : Base, Mixin { // don't need to implement foo() since Base defined it } So to work correctly in the CLR we need to trap this case and emit a virtual router method on child to satisfy the interface requirement: class Child : Base, Mixin { public virtual Long foo() { return base.foo(); } } TODO - optimize the intra-pod case
public emitInterfaceRouter ( Type implType, Method m ) : void
implType Fan.Sys.Type
m Fan.Sys.Method
return void

emitMixinBody() public method

public emitMixinBody ( ) : void
return void

emitMixinInterface() public method

Emit the method as a mixin interface
public emitMixinInterface ( ) : void
return void

emitMixinRouter() public method

Emit a mixin router from a class to the mixin body methods.
public emitMixinRouter ( Method m ) : void
m Fan.Sys.Method
return void

emitNative() public method

public emitNative ( ) : void
return void

emitStandard() public method

Emit a standard instance/static class method.
public emitStandard ( ) : void
return void