Represents a class being compiled from a nitro code string.
Public Member Functions | |
CompiledClass () | |
Creates a new class. Note you must call StartType manually. More... | |
CompiledClass (CodeFragment classFragment, NitroCode script, string name, Type baseType, bool isPublic) | |
void | StartType (string name, NitroCode script, Type baseType) |
Starts creating this class. More... | |
Type | GetAsType () |
Gets this class as a system type. More... | |
void | Compile () |
Compiles this class from its ClassFragment. More... | |
bool | ContainsMethod (string name) |
Checks if this class contains the method with the given name. More... | |
bool | ContainsField (string field) |
Checks if this class contains the field with the given name. More... | |
Type | MethodReturnType (string name) |
Gets the return type of a given method by name. Note all overloads must return the same thing. More... | |
MethodInfo | FindMethodOverload (string name, CompiledFragment[] arguments) |
Gets a particular method (it may be overloaded) from this class. More... | |
MethodInfo | FindMethodOverload (string name, Type[] arguments) |
Gets a particular method (it may be overloaded) from this class. More... | |
MethodOverloads | FindMethodSet (string name) |
Finds the overload set for the method with the given name. More... | |
PropertyInfo | GetProperty (string name) |
Gets the property from this class with the given name. More... | |
FieldInfo | GetField (string name) |
Gets the field from this class with the given name. More... | |
void | FindOperations (CodeFragment fragment) |
Finds any other entries in the given code fragment. More... | |
void | FindMethods (CodeFragment fragment) |
Finds methods within the given fragment by looking for 'function'. More... | |
Public Attributes | |
Type | BaseType |
The type that this class derives from, if any. More... | |
Type | compiledType |
When fully compiled, this is the resulting system type of this class. More... | |
NitroCode | Script |
The script this class belongs to. More... | |
bool | IsPublic =true |
True if this is a public class, false for private. More... | |
TypeBuilder | Builder |
The type builder used to construct a system type from this class. More... | |
CodeFragment | ClassFragment |
The content of this whole class as parsed from the code. More... | |
Dictionary< string, FieldInfo > | Fields =new Dictionary<string,FieldInfo>() |
All the fields of this class. More... | |
Dictionary< string, MethodOverloads > | Methods =new Dictionary<string,MethodOverloads>() |
All methods contained by this class grouped into overloads. More... | |
Protected Member Functions | |
virtual CodeFragment | AddFoundMethod (CodeFragment fragment, CodeFragment body, string name, bool anonymous, BracketFragment parameters, TypeFragment returnType, bool isPublic) |
Adds a method that was found into this classes set of methods to compile. More... | |
Protected Attributes | |
int | AnonymousCount |
A counter used to name anonymous methods. More... | |
Package Functions | |
virtual FieldInfo | DefineField (string name, bool isPublic, Type type) |
Defines a new field on this class. More... | |
Private Member Functions | |
MethodOverloads | MakeOrFind (string name, Type returnType) |
Finds the method overload set with the given name and creates it if it doesn't exist. More... | |
void | GloballyScope (CodeFragment fragment) |
Globally scopes the given fragment. This is like stripping the word 'var' from any discovered properties. More... | |
CompiledMethod | GetStartMethod () |
Gets the OnScriptReady method. May create it if it's not available. More... | |
CompiledMethod | GetInit () |
Gets the init method. May create it if it's not already available. More... | |
|
inline |
Creates a new class. Note you must call StartType manually.
|
inline |
|
inlineprotectedvirtual |
Adds a method that was found into this classes set of methods to compile.
fragment | The first fragment of the method, used for generating errors. This gives a valid line number. |
body | The block of code for this method. |
name | The name of the method. Null if anonymous is true. |
anonymous | True if this method is an anonymous one and requires a name. |
parameters | The set of parameters for this method. |
returnType | The type that this method returns. |
isPublic | True if this is a public method; false for private. |
|
inline |
Compiles this class from its ClassFragment.
|
inline |
Checks if this class contains the field with the given name.
field | The name of the field to look for. |
|
inline |
Checks if this class contains the method with the given name.
name | The name of the method to look for. |
|
inlinepackagevirtual |
Defines a new field on this class.
name | The name of the field. |
type | The type of the value held by this field. |
|
inline |
Gets a particular method (it may be overloaded) from this class.
name | The name of the method. |
<param name=arguments">The set of arguments being used in calling this method.
|
inline |
Gets a particular method (it may be overloaded) from this class.
name | The name of the method. |
<param name=arguments">The types of the set of arguments being used in calling this method.
|
inline |
Finds methods within the given fragment by looking for 'function'.
fragment | The fragment to search. |
|
inline |
Finds the overload set for the method with the given name.
name | The name of the method. |
|
inline |
Finds any other entries in the given code fragment.
fragment | The fragment to search. |
|
inline |
Gets this class as a system type.
|
inline |
Gets the field from this class with the given name.
name | The name to look for. |
|
inlineprivate |
Gets the init method. May create it if it's not already available.
|
inline |
Gets the property from this class with the given name.
name | The name to look for. |
|
inlineprivate |
Gets the OnScriptReady method. May create it if it's not available.
|
inlineprivate |
Globally scopes the given fragment. This is like stripping the word 'var' from any discovered properties.
|
inlineprivate |
Finds the method overload set with the given name and creates it if it doesn't exist.
name | The name of the method. |
returnType | The type that this method returns. |
|
inline |
Gets the return type of a given method by name. Note all overloads must return the same thing.
Starts creating this class.
name | The name of the class. |
script | The parent script this class belongs to. |
baseType | The type that this class will derive from. |
|
protected |
A counter used to name anonymous methods.
Type Nitro.CompiledClass.BaseType |
The type that this class derives from, if any.
TypeBuilder Nitro.CompiledClass.Builder |
The type builder used to construct a system type from this class.
CodeFragment Nitro.CompiledClass.ClassFragment |
The content of this whole class as parsed from the code.
Type Nitro.CompiledClass.compiledType |
When fully compiled, this is the resulting system type of this class.
Dictionary<string,FieldInfo> Nitro.CompiledClass.Fields =new Dictionary<string,FieldInfo>() |
All the fields of this class.
bool Nitro.CompiledClass.IsPublic =true |
True if this is a public class, false for private.
Dictionary<string,MethodOverloads> Nitro.CompiledClass.Methods =new Dictionary<string,MethodOverloads>() |
All methods contained by this class grouped into overloads.
NitroCode Nitro.CompiledClass.Script |
The script this class belongs to.