Detailed Description

Represents a compiled operation which can be emitted to IL.

Inheritance diagram for Nitro.Operation:
Nitro.CompiledFragment Nitro.CodeFragment Nitro.AddOperation Nitro.AndOperation Nitro.ArrayOperation Nitro.BaseOperation Nitro.BitwiseXOrOperation Nitro.BoxOperation Nitro.BreakOperation Nitro.CastOperation Nitro.ConstructOperation Nitro.ContinueOperation Nitro.DivideOperation Nitro.EqualsOperation Nitro.ForOperation Nitro.GreaterThanOperation Nitro.IfOperation Nitro.IndexOperation Nitro.LessThanOperation Nitro.MethodOperation Nitro.ModuloOperation Nitro.MultiplyOperation Nitro.OrOperation Nitro.PropertyOperation Nitro.ReturnOperation Nitro.SetOperation Nitro.ShiftLeftOperation Nitro.ShiftRightOperation Nitro.SubtractOperation Nitro.SwitchOperation Nitro.ThisOperation Nitro.TypeOperation Nitro.UnboxOperation

Public Member Functions

 Operation (CompiledMethod method)
 Creates a new operation that is part of the given method. More...
 
override int GetLineNumber ()
 Returns the line number this fragment came from. More...
 
override bool IsConstant ()
 Checks if this fragment is a constant value. More...
 
bool IsSet ()
 Checks if this operation is part of a set operation. More...
 
Type EnforceType (ref CompiledFragment input, Type inputType, Type newType)
 Forces this operation to be a particular type by creating a cast. More...
 
Type Numerical (ref CompiledFragment input, Type inputType, Type defaultType)
 Forces this operation to have a numerical output. More...
 
Type Numerical (Type typeA, Type typeB, string overloadMethod, ref CompiledFragment newOperation)
 Attempts to find the named numerical operation that the given types can perform. More...
 
Type MapNumerical (Type typeA, Type typeB)
 Attempts to make both Input0 and Input1 numerical, returning the output result of an operation if they are. Usually the returned type will be the one with higher accuracy. E.g. adding an int to a long will result in a long. More...
 
Type FindOverload (string methodName, Type typeA, Type typeB, ref CompiledFragment newOperation)
 Looks for an overloaded numerical operator by the given name (e.g. "Addition"). The name will then have op_ appended to the start of it (as used internally by .NET). If found, the output type of the operation is returned. More...
 
- Public Member Functions inherited from Nitro.CompiledFragment
 CompiledFragment ()
 An empty constructor used for inheriting this class. More...
 
object ActiveValue ()
 Gets the active value of this fragment. More...
 
 CompiledFragment (object value)
 Creates a new compiled fragment for the given constant value. More...
 
bool IsLogical ()
 Checks if this fragment can be used logically. More...
 
Type OutputType ()
 Returns the type that this fragment produces when it's executed. For example, int+int will output another int. This must only be used when it's known that a fragment won't replace itself. More...
 
virtual Type OutputType (out CompiledFragment v)
 Returns the type that this fragment produces when it's executed. For example, int+int will output another int. More...
 
override CompiledFragment Compile (CompiledMethod method)
 Compiles this CodeFragment into a CompiledFragment. More...
 
virtual void OutputIL (NitroIL into)
 Generates the IL of this operation into the given stream. More...
 
void EmitValue (Type type, NitroIL into)
 Emits the Value held by this compiled fragment if possible. More...
 
- Public Member Functions inherited from Nitro.CodeFragment
void Error (string message)
 Throws an error, outputting the line number it occured on. More...
 
virtual bool IsMemberAccessor ()
 A value which states if this fragment accesses members (methods/fields) of something. More...
 
void AddToStart (CodeFragment parent)
 Adds this code fragment to the beginning of the given parents child set. More...
 
void AddBefore (CodeFragment frag)
 Adds this code fragment as a child before the given one. More...
 
void AddAfter (CodeFragment frag)
 Adds this code fragment as a child after the given one. More...
 
void Remove ()
 Removes this fragment from its parent. More...
 
void AddChild (CodeFragment child)
 Adds the given fragment as a child of this one. More...
 
virtual bool Typeable ()
 Defines if a fragment can be given a :TYPE. E.g. Brackets (for casting, (A):TYPE) and variables can. More...
 
int ChildCount ()
 How many children does this fragment have? More...
 
virtual AddResult AddTo (CodeFragment to, CodeLexer sr)
 Adds this fragment as a child to the given fragment. It may be overriden by some types of fragment as they may wish to handle it differently. More...
 
override string ToString ()
 Converts this fragment into a code string. More...
 

Public Attributes

int LineNumber =-1
 The line number this operation originates from. More...
 
CompiledMethod Method
 The method that this operation belongs to. More...
 
CompiledFragment Input0
 The first input to this operation. Often the input to the left of an operator. Input0+Input1. More...
 
CompiledFragment Input1
 The second input to this operation. Often the input to the right of an operator. Input0+Input1. More...
 
- Public Attributes inherited from Nitro.CompiledFragment
object Value
 A constant value if this fragment has one. E.g. strings, ints etc. go here. More...
 
- Public Attributes inherited from Nitro.CodeFragment
TypeFragment GivenType
 A type (:TYPE) which was explicitly given to this block. More...
 
CodeFragment NextChild
 The child after this one. More...
 
CodeFragment LastChild
 The last child of this fragment, stored as a linked list. More...
 
CodeFragment FirstChild
 The first child of this fragment, stored as a linked list. More...
 
CodeFragment PreviousChild
 The child before this one. More...
 
CodeFragment ParentFragment
 The parent fragment of this, if any. More...
 

Properties

virtual bool RequiresStoring [get]
 This operation requires you "storing" its output. A variable does; for(){} does not. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Nitro.CodeFragment
static int IsOfType (char[] arrayToSearch, char charToFind)
 Returns the index in the given array of the given character if it's found in it. More...
 

Constructor & Destructor Documentation

Nitro.Operation.Operation ( CompiledMethod  method)
inline

Creates a new operation that is part of the given method.

Parameters
methodThe method that this operation belongs to.

Member Function Documentation

Type Nitro.Operation.EnforceType ( ref CompiledFragment  input,
Type  inputType,
Type  newType 
)
inline

Forces this operation to be a particular type by creating a cast.

Parameters
inputA reference to this operation which may be replaced with a cast operation.
inputTypeThe current output type of this operation.
newTypeThe type that the output of this operation must be.
Returns
The new output type if successful. Throws an error otherwise.
Type Nitro.Operation.FindOverload ( string  methodName,
Type  typeA,
Type  typeB,
ref CompiledFragment  newOperation 
)
inline

Looks for an overloaded numerical operator by the given name (e.g. "Addition"). The name will then have op_ appended to the start of it (as used internally by .NET). If found, the output type of the operation is returned.

Parameters
methodNameThe name of the method to look for.
typeAThe type of the input on the left of the operator (Input0).
typeBThe type of the input on the right of the operator (Input1).
newOperationA method call operation if it was found which is already correctly linked to Input0 and Input1.
Returns
The output type of the method if found.
override int Nitro.Operation.GetLineNumber ( )
inlinevirtual

Returns the line number this fragment came from.

Reimplemented from Nitro.CodeFragment.

override bool Nitro.Operation.IsConstant ( )
inlinevirtual

Checks if this fragment is a constant value.

Returns
True if it's a constant; false otherwise.

Reimplemented from Nitro.CompiledFragment.

bool Nitro.Operation.IsSet ( )
inline

Checks if this operation is part of a set operation.

Returns
True if a set operation is anywhere in the hierarchy of this operation; false otherwise.
Type Nitro.Operation.MapNumerical ( Type  typeA,
Type  typeB 
)
inline

Attempts to make both Input0 and Input1 numerical, returning the output result of an operation if they are. Usually the returned type will be the one with higher accuracy. E.g. adding an int to a long will result in a long.

Parameters
typeAThe output type of Input0.
typeBThe output type of Input1.
Returns
The output result of a numerical operation with these types.
Type Nitro.Operation.Numerical ( ref CompiledFragment  input,
Type  inputType,
Type  defaultType 
)
inline

Forces this operation to have a numerical output.

Parameters
inputA reference to this operation which may be replaced with a cast operation.
inputTypeThe current output type of this operation.
newTypeThe type that the output of this operation must be.
Returns
The new output type if successful. Throws an error otherwise.
Type Nitro.Operation.Numerical ( Type  typeA,
Type  typeB,
string  overloadMethod,
ref CompiledFragment  newOperation 
)
inline

Attempts to find the named numerical operation that the given types can perform.

Parameters
typeAThe type of the object on the left of the operator.
typeBThe type of the object on the right of the operator.
overloadMethodThe name of the method to look for, e.g. "Addition".
newOperationThe new method call if it was successfully found.
Returns
The new output type if successful. Throws an error otherwise.

Member Data Documentation

CompiledFragment Nitro.Operation.Input0

The first input to this operation. Often the input to the left of an operator. Input0+Input1.

CompiledFragment Nitro.Operation.Input1

The second input to this operation. Often the input to the right of an operator. Input0+Input1.

int Nitro.Operation.LineNumber =-1

The line number this operation originates from.

CompiledMethod Nitro.Operation.Method

The method that this operation belongs to.

Property Documentation

virtual bool Nitro.Operation.RequiresStoring
get

This operation requires you "storing" its output. A variable does; for(){} does not.