Class MethodBody
A method body: a method implementation represented as a control-flow graph along with a private copy of the return parameter, 'this' parameter and input parameters.
Inheritance
Inherited Members
Namespace: Flame.Compiler
Assembly: Flame.Compiler.dll
Syntax
public sealed class MethodBody
Constructors
| Improve this Doc View SourceMethodBody(Parameter, Parameter, IReadOnlyList<Parameter>, FlowGraph)
Creates a method implementation.
Declaration
public MethodBody(Parameter returnParameter, Parameter thisParameter, IReadOnlyList<Parameter> parameters, FlowGraph implementation)
Parameters
Type | Name | Description |
---|---|---|
Parameter | returnParameter | The method implementation's return parameter. |
Parameter | thisParameter | The method implementation's 'this' parameter. |
System.Collections.Generic.IReadOnlyList<Parameter> | parameters | The method implementation's input parameters. |
FlowGraph | implementation | The method implementation, represented as a control-flow graph. |
Properties
| Improve this Doc View SourceImplementation
Gets the control-flow graph that constitutes the method implementation.
Declaration
public FlowGraph Implementation { get; }
Property Value
Type | Description |
---|---|
FlowGraph | The method implementation. |
Members
Gets a sequence that contains all members that appear in the method body.
Declaration
public IEnumerable<IMember> Members { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IMember> | A sequence of types, methods and fields. |
Parameters
Gets the method implementation's input parameter list.
Declaration
public IReadOnlyList<Parameter> Parameters { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<Parameter> | The parameter list. |
ReturnParameter
Gets the method implementation's return parameter.
Declaration
public Parameter ReturnParameter { get; }
Property Value
Type | Description |
---|---|
Parameter | The return parameter. |
ThisParameter
Gets the method implementation's 'this' parameter, if any.
Declaration
public Parameter ThisParameter { get; }
Property Value
Type | Description |
---|---|
Parameter | The 'this' parameter. |
Methods
| Improve this Doc View SourceMap(MemberMapping)
Applies a member mapping to this method body's implementation, 'this' parameter, parameter list and return parameter. The result is returned as a new method body.
Declaration
public MethodBody Map(MemberMapping memberMapping)
Parameters
Type | Name | Description |
---|---|---|
MemberMapping | memberMapping | The member mapping to apply. |
Returns
Type | Description |
---|---|
MethodBody | A new method body. |
Validate()
Validates this method body and returns a list of error messages.
Declaration
public IReadOnlyList<string> Validate()
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<System.String> | A list of error messages. |
WithImplementation(FlowGraph)
Creates a method body based on this method body, but with a different implementation.
Declaration
public MethodBody WithImplementation(FlowGraph newImplementation)
Parameters
Type | Name | Description |
---|---|---|
FlowGraph | newImplementation | The implementation of the method body to create. |
Returns
Type | Description |
---|---|
MethodBody | A new method body. |