Detailed Description

Represents a fragment of the text input code. Once compiled, it becomes a CompiledFragment. CompiledFragments are also types of CodeFragment as this allows them to be parented into the original structure.

Inheritance diagram for Nitro.CodeFragment:
Nitro.ArrayFragment Nitro.BracketFragment Nitro.CompiledFragment Nitro.ConstructorFragment Nitro.ForFragment Nitro.IfFragment Nitro.IndexFragment Nitro.MethodFragment Nitro.NumberFragment Nitro.OperationFragment Nitro.OperatorFragment Nitro.PropertyFragment Nitro.StringFragment Nitro.SwitchFragment Nitro.TypeFragment Nitro.VariableFragment

Public Member Functions

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...
 
virtual CompiledFragment Compile (CompiledMethod method)
 Attempts to compile this fragment into the given method. 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...
 

Static Public Member Functions

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

Public Attributes

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

bool IsParent [get]
 Is this fragment a parent or not? More...
 

Member Function Documentation

void Nitro.CodeFragment.AddAfter ( CodeFragment  frag)
inline

Adds this code fragment as a child after the given one.

Parameters
fragThe fragment to add this one after.
void Nitro.CodeFragment.AddBefore ( CodeFragment  frag)
inline

Adds this code fragment as a child before the given one.

Parameters
fragThe fragment to add this before.
void Nitro.CodeFragment.AddChild ( CodeFragment  child)
inline

Adds the given fragment as a child of this one.

Parameters
childThe fragment to add as a child.
virtual AddResult Nitro.CodeFragment.AddTo ( CodeFragment  to,
CodeLexer  sr 
)
inlinevirtual

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.

Parameters
toThe parent to add this fragment to.
srThe lexer containing the original text code.

Reimplemented in Nitro.BracketFragment, Nitro.TypeFragment, Nitro.VariableFragment, Nitro.PropertyFragment, Nitro.IfFragment, Nitro.MethodFragment, Nitro.ForFragment, and Nitro.SwitchFragment.

void Nitro.CodeFragment.AddToStart ( CodeFragment  parent)
inline

Adds this code fragment to the beginning of the given parents child set.

Parameters
parentThe parent to parent this fragment to.
int Nitro.CodeFragment.ChildCount ( )
inline

How many children does this fragment have?

Returns
The number of children.
virtual CompiledFragment Nitro.CodeFragment.Compile ( CompiledMethod  method)
inlinevirtual
void Nitro.CodeFragment.Error ( string  message)
inline

Throws an error, outputting the line number it occured on.

Parameters
messageA message saying why this error occured.
virtual int Nitro.CodeFragment.GetLineNumber ( )
inlinevirtual

Returns the line number this fragment came from.

Reimplemented in Nitro.OperationFragment, Nitro.VariableFragment, and Nitro.Operation.

virtual bool Nitro.CodeFragment.IsMemberAccessor ( )
inlinevirtual

A value which states if this fragment accesses members (methods/fields) of something.

Returns
True if this fragment is a PropertyOperation or a MethodOperation; false otherwise.

Reimplemented in Nitro.MethodOperation, and Nitro.PropertyOperation.

static int Nitro.CodeFragment.IsOfType ( char[]  arrayToSearch,
char  charToFind 
)
inlinestatic

Returns the index in the given array of the given character if it's found in it.

Parameters
arrayToSearchThe set of characters to look through.
charToFindThe character to find in the set.
Returns
The index in the set, if found; -1 otherwise.
void Nitro.CodeFragment.Remove ( )
inline

Removes this fragment from its parent.

override string Nitro.CodeFragment.ToString ( )
inline

Converts this fragment into a code string.

virtual bool Nitro.CodeFragment.Typeable ( )
inlinevirtual

Defines if a fragment can be given a :TYPE. E.g. Brackets (for casting, (A):TYPE) and variables can.

Returns
True if it can, false otherwise.

Reimplemented in Nitro.BracketFragment, Nitro.VariableFragment, and Nitro.MethodFragment.

Member Data Documentation

CodeFragment Nitro.CodeFragment.FirstChild

The first child of this fragment, stored as a linked list.

TypeFragment Nitro.CodeFragment.GivenType

A type (:TYPE) which was explicitly given to this block.

CodeFragment Nitro.CodeFragment.LastChild

The last child of this fragment, stored as a linked list.

CodeFragment Nitro.CodeFragment.NextChild

The child after this one.

CodeFragment Nitro.CodeFragment.ParentFragment

The parent fragment of this, if any.

CodeFragment Nitro.CodeFragment.PreviousChild

The child before this one.

Property Documentation

bool Nitro.CodeFragment.IsParent
get

Is this fragment a parent or not?

Returns
True if it is, false otherwise.