Nitro.CompiledFragment Class Reference

Detailed Description

Represents a code fragment that has been compiled and can now be written out as IL.

Inheritance diagram for Nitro.CompiledFragment:
Nitro.CodeFragment Nitro.Operation 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

 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...
 
virtual bool IsConstant ()
 Checks if this fragment is a 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...
 
virtual int GetLineNumber ()
 Returns the line number this fragment came from. 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

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...
 

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...
 
- Properties inherited from Nitro.CodeFragment
bool IsParent [get]
 Is this fragment a parent or not? More...
 

Constructor & Destructor Documentation

Nitro.CompiledFragment.CompiledFragment ( )
inline

An empty constructor used for inheriting this class.

Nitro.CompiledFragment.CompiledFragment ( object  value)
inline

Creates a new compiled fragment for the given constant value.

Parameters
valueThe constant value for this fragment.

Member Function Documentation

object Nitro.CompiledFragment.ActiveValue ( )
inline

Gets the active value of this fragment.

Returns
If this fragment is a constant, the active value is the constant itself. Otherwise, the active value is the actual fragment.
override CompiledFragment Nitro.CompiledFragment.Compile ( CompiledMethod  method)
inlinevirtual

Compiles this CodeFragment into a CompiledFragment.

Parameters
methodThe method that this fragment occurs in.
Returns
A CompiledFragment is already compiled, so it returns itself. This is called in nested operations.

Reimplemented from Nitro.CodeFragment.

void Nitro.CompiledFragment.EmitValue ( Type  type,
NitroIL  into 
)
inline

Emits the Value held by this compiled fragment if possible.

Parameters
typeThe type of the value (or one of the base types of the value).
intoThe IL stream to output the IL into.
virtual bool Nitro.CompiledFragment.IsConstant ( )
inlinevirtual

Checks if this fragment is a constant value.

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

Reimplemented in Nitro.Operation.

bool Nitro.CompiledFragment.IsLogical ( )
inline

Checks if this fragment can be used logically.

Returns
True if this operation returns a boolean.
Type Nitro.CompiledFragment.OutputType ( )
inline

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.

Returns
The type that this fragment returns.
virtual Type Nitro.CompiledFragment.OutputType ( out CompiledFragment  v)
inlinevirtual

Returns the type that this fragment produces when it's executed. For example, int+int will output another int.

Parameters
vIn some cases, checking the output type will generate a new fragment. This value is the new fragment and it must always replace the original fragment that OutputType was called on.
Returns
The type that this fragment returns.

Reimplemented in Nitro.MethodOperation, Nitro.PropertyOperation, Nitro.SwitchOperation, Nitro.ConstructOperation, Nitro.ArrayOperation, Nitro.IfOperation, Nitro.IndexOperation, Nitro.ForOperation, Nitro.BreakOperation, Nitro.SetOperation, Nitro.ContinueOperation, Nitro.CastOperation, Nitro.UnboxOperation, Nitro.BoxOperation, Nitro.ReturnOperation, Nitro.TypeOperation, Nitro.AddOperation, Nitro.AndOperation, Nitro.BitwiseXOrOperation, Nitro.DivideOperation, Nitro.EqualsOperation, Nitro.GreaterThanOperation, Nitro.LessThanOperation, Nitro.ModuloOperation, Nitro.MultiplyOperation, Nitro.OrOperation, Nitro.ShiftLeftOperation, Nitro.ShiftRightOperation, Nitro.SubtractOperation, Nitro.BaseOperation, and Nitro.ThisOperation.

Member Data Documentation

object Nitro.CompiledFragment.Value

A constant value if this fragment has one. E.g. strings, ints etc. go here.