Detailed Description

Represents a method/function that is currently being compiled.

Public Member Functions

 CompiledMethod (string name)
 
 CompiledMethod (CompiledClass parent, string name, BracketFragment parameterBlock, BracketFragment codeBlock, TypeFragment retType, int line, bool isPublic)
 
void AddBreakPoint (BreakPoint bp)
 Adds a breakpoint to the set of breakpoints for this method. More...
 
void PopBreakPoint ()
 Removes a breakpoint from the set of breakpoints for this method. More...
 
bool Break (NitroIL into, int depth)
 Adds a break into the given IL stream, breaking out of the given number of loops. More...
 
bool Continue (NitroIL into, int depth)
 Adds a continue into the given IL stream, continuing at the given number of loops up. More...
 
void Done ()
 Called when this method is finished compiling this method. More...
 
void Error (string message)
 Throws an error that occured in the compilation of this method with the given message. More...
 
Type ReturnType ()
 Gets the return type of this method. More...
 
MethodInfo getMethodInfo ()
 Gets the MethodInfo for this method. More...
 
ParameterVariable GetParameter (string variableName)
 Attempts to find the parameter by the given name. More...
 
LocalVariable GetLocal (string variableName)
 Attempts to find the local variable by the given name. More...
 
LocalVariable GetLocal (string variableName, bool create, Type createType)
 Attempts to find the local by the given name and optionally creates it if it's not found. More...
 
Variable GetVariable (string name)
 Attempts to get either a local variable or a parameter by the given name. More...
 
Variable GetVariable (string name, bool create, Type createType)
 Attempts to get either a local variable or a parameter by the given name, creating it if not found. More...
 
Variable GetVariable (string name, VariableType type, bool create, Type createType)
 Attempts to get either a variable of the given type by the given name, creating it if not found. More...
 

Public Attributes

int Line
 The line the method starts on. More...
 
string Name
 The name of the method. More...
 
NitroCode Script
 The script that this method belongs to. More...
 
NitroIL ILStream
 The IL stream for this method. This is what will make this method executable. More...
 
Label EndOfMethod
 The location at the end of the method. More...
 
bool GloballyScoped
 True if any variables in this method should be declared on the class. More...
 
CompiledClass Parent
 The class that this method belongs to. More...
 
bool ParametersLoaded
 True if the parameter types have been parsed. More...
 
MethodBuilder Builder
 A method builder which provides the ILGenerator. More...
 
Type[] ParameterTypes
 The types of each parameter that this method accepts. More...
 
LocalBuilder ReturnBay
 A location that the return value is placed into. More...
 
BracketFragment CodeBlock
 The block of code that represents the body of this method. More...
 
BracketFragment ParameterBlock
 The bracket fragment that contains the set of parameters. More...
 
CompiledFragment[] DefaultParameterValues
 Default values for the parameters, if any are provided. More...
 
List< BreakPointBreakPoints =new List<BreakPoint>()
 A list which acts like a stack of breakpoints for breaking from nested loops. More...
 
Dictionary< string, LocalVariableLocalSet =new Dictionary<string,LocalVariable>()
 A fast lookup of variable name to local variable. More...
 
Dictionary< string,
ParameterVariable
ParameterSet =new Dictionary<string,ParameterVariable>()
 A fast lookup of variable name to parameter variable. More...
 

Private Member Functions

void ParametersOk ()
 Confirms that the recently loaded parameters are valid. More...
 
void ParseParameters ()
 Loads the parameter block into a set of types. More...
 
void ApplyParameters ()
 

Constructor & Destructor Documentation

Nitro.CompiledMethod.CompiledMethod ( string  name)
inline
Nitro.CompiledMethod.CompiledMethod ( CompiledClass  parent,
string  name,
BracketFragment  parameterBlock,
BracketFragment  codeBlock,
TypeFragment  retType,
int  line,
bool  isPublic 
)
inline

Member Function Documentation

void Nitro.CompiledMethod.AddBreakPoint ( BreakPoint  bp)
inline

Adds a breakpoint to the set of breakpoints for this method.

Parameters
bpThe breakpoint to add.
void Nitro.CompiledMethod.ApplyParameters ( )
inlineprivate
bool Nitro.CompiledMethod.Break ( NitroIL  into,
int  depth 
)
inline

Adds a break into the given IL stream, breaking out of the given number of loops.

Parameters
intoThe IL stream to emit the break into.
depthThe amount of loops to break from. Can be affected with e.g. break 2; for getting out of a loop in a loop.
Returns
True if it could locate the loop and added the command.
bool Nitro.CompiledMethod.Continue ( NitroIL  into,
int  depth 
)
inline

Adds a continue into the given IL stream, continuing at the given number of loops up.

Parameters
intoThe IL stream to emit the continue into.
depthThe loop to continue in. Can be affected with e.g. continue 2; for continuing the outer loop of a loop in a loop.
Returns
True if it could locate the loop and added the command.
void Nitro.CompiledMethod.Done ( )
inline

Called when this method is finished compiling this method.

void Nitro.CompiledMethod.Error ( string  message)
inline

Throws an error that occured in the compilation of this method with the given message.

Parameters
messageA message to state why this error occured.
LocalVariable Nitro.CompiledMethod.GetLocal ( string  variableName)
inline

Attempts to find the local variable by the given name.

Parameters
variableNameThe name of the local variable to find.
Returns
The variable, if found. Null otherwise.
LocalVariable Nitro.CompiledMethod.GetLocal ( string  variableName,
bool  create,
Type  createType 
)
inline

Attempts to find the local by the given name and optionally creates it if it's not found.

Parameters
variableNameThe name of the local to find.
createTrue if it should be created if not found.
createTypeIf create is true, the type of the variable to create. If it's null, object is assumed.
Returns
The local, if found or created. Null otherwise.
MethodInfo Nitro.CompiledMethod.getMethodInfo ( )
inline

Gets the MethodInfo for this method.

Returns
The MethodInfo for this method.
ParameterVariable Nitro.CompiledMethod.GetParameter ( string  variableName)
inline

Attempts to find the parameter by the given name.

Parameters
variableNameThe name of the parameter to find.
Returns
The parameter, if found. Null otherwise.
Variable Nitro.CompiledMethod.GetVariable ( string  name)
inline

Attempts to get either a local variable or a parameter by the given name.

Parameters
nameThe name of the variable to find.
Returns
The variable, if found. Null otherwise.
Variable Nitro.CompiledMethod.GetVariable ( string  name,
bool  create,
Type  createType 
)
inline

Attempts to get either a local variable or a parameter by the given name, creating it if not found.

Parameters
nameThe name of the variable to find.
createTrue if it should be created if not found. Will always make a local.
createTypeIf create is true, the type of the variable to create. If it's null, object is assumed.
Returns
The variable, if found. Null otherwise.
Variable Nitro.CompiledMethod.GetVariable ( string  name,
VariableType  type,
bool  create,
Type  createType 
)
inline

Attempts to get either a variable of the given type by the given name, creating it if not found.

Parameters
nameThe name of the variable to find.
typeThe type of the variable to find. Local, Parameter or Any.
createTrue if it should be created if not found. Will always make a local.
createTypeIf create is true, the type of the variable to create. If it's null, object is assumed.
Returns
The variable, if found. Null otherwise.
void Nitro.CompiledMethod.ParametersOk ( )
inlineprivate

Confirms that the recently loaded parameters are valid.

void Nitro.CompiledMethod.ParseParameters ( )
inlineprivate

Loads the parameter block into a set of types.

void Nitro.CompiledMethod.PopBreakPoint ( )
inline

Removes a breakpoint from the set of breakpoints for this method.

Type Nitro.CompiledMethod.ReturnType ( )
inline

Gets the return type of this method.

Returns
The return type of this method.

Member Data Documentation

List<BreakPoint> Nitro.CompiledMethod.BreakPoints =new List<BreakPoint>()

A list which acts like a stack of breakpoints for breaking from nested loops.

MethodBuilder Nitro.CompiledMethod.Builder

A method builder which provides the ILGenerator.

BracketFragment Nitro.CompiledMethod.CodeBlock

The block of code that represents the body of this method.

CompiledFragment [] Nitro.CompiledMethod.DefaultParameterValues

Default values for the parameters, if any are provided.

Label Nitro.CompiledMethod.EndOfMethod

The location at the end of the method.

bool Nitro.CompiledMethod.GloballyScoped

True if any variables in this method should be declared on the class.

NitroIL Nitro.CompiledMethod.ILStream

The IL stream for this method. This is what will make this method executable.

int Nitro.CompiledMethod.Line

The line the method starts on.

Dictionary<string,LocalVariable> Nitro.CompiledMethod.LocalSet =new Dictionary<string,LocalVariable>()

A fast lookup of variable name to local variable.

string Nitro.CompiledMethod.Name

The name of the method.

BracketFragment Nitro.CompiledMethod.ParameterBlock

The bracket fragment that contains the set of parameters.

Dictionary<string,ParameterVariable> Nitro.CompiledMethod.ParameterSet =new Dictionary<string,ParameterVariable>()

A fast lookup of variable name to parameter variable.

bool Nitro.CompiledMethod.ParametersLoaded

True if the parameter types have been parsed.

Type [] Nitro.CompiledMethod.ParameterTypes

The types of each parameter that this method accepts.

CompiledClass Nitro.CompiledMethod.Parent

The class that this method belongs to.

LocalBuilder Nitro.CompiledMethod.ReturnBay

A location that the return value is placed into.

NitroCode Nitro.CompiledMethod.Script

The script that this method belongs to.