Detailed Description

Global methods that relate to handling variable types and changing/ casting between them.

Static Public Member Functions

static bool IsNumeric (Type type)
 True if the given type is a numeric one (e.g. a float, int etc). More...
 
static MethodInfo GetCallable (Type type)
 Gets the Run method on the given type. More...
 
static ConstructorInfo GetConstructor (Type type, CompiledFragment[] args)
 Gets the constructor overload for the given type and using the given arguments. More...
 
static string SetToString (ParameterInfo[] set)
 Converts the given set of parameters into a string of name:Type, seperated by commas. More...
 
static bool IsParams (ParameterInfo param)
 Checks if the given ParameterInfo uses the params keyword. More...
 
static bool IsDynamic (MemberInfo member)
 Checks if the given member is from a class being compiled at the moment. More...
 
static int WillAccept (Type[] args, ParameterInfo[] parameters, bool withCasting)
 Checks if the given parameter set will accept the given argument set. Used to find an overload. More...
 
static bool NoReturn (MethodInfo methodInfo)
 Checks if the given method doesn't return anything. More...
 
static bool IsVoid (Type T)
 Checks if the given type is either a system or nitro void. More...
 
static void OutputParameters (CompiledFragment[] args, CompiledMethod method, NitroIL into, ParameterInfo[] parameters)
 Outputs the given argument set into the given IL stream. More...
 
static Type MethodReturnType (Type type, string name)
 Gets the return type of a named method on the given type. Note that all overloads must return the same type in Nitro. More...
 
static MethodInfo GetOverload (MethodInfo[] overloads, string name, Type[] argSet)
 Gets the MethodInfo from the given set of methods which matches the given argument set and name. More...
 
static MethodInfo GetOverload (MethodInfo[] overloads, string name, Type[] argSet, bool ignoreCase)
 Gets the MethodInfo from the given set of methods which matches the given argument set and name. More...
 
static bool TypeSetsMatch (Type[] a, Type[] b)
 Checks if A and B match. Note that types in A can derive (inherit) types in set B. More...
 
static bool TypeSetsMatchExactly (Type[] a, Type[] b)
 Checks if the given type sets match exactly with no inheritance allowed. More...
 
static MethodOperation ToStringMethod (CompiledMethod method, CompiledFragment frag, Type type)
 Gets the ToString method of the given type, being called on the given fragment. More...
 
static CompiledFragment TryCast (CompiledMethod method, CompiledFragment frag, Type to)
 Attempts to generate a cast operation for the given fragment to the given type. More...
 
static CompiledFragment TryCast (CompiledMethod method, CompiledFragment frag, Type to, out bool isExplicit)
 Attempts to generate a cast operation for the given fragment to the given type. More...
 
static string NameWithoutNamespace (string typeName)
 Gets the name of a type without the namespace. E.g. System.Int32 becomes Int32. More...
 
static MethodInfo IsCastableTo (Type from, Type to, out bool isExplicit)
 Checks if one type is castable to another, reporting if it must be done explicitly or not if its possible. More...
 
static Type[] GetTypes (CompiledFragment[] frags)
 Converts a set of compiled fragments into a set of their outputted types. E.g. if a certain fragment is "a string", one of the types will be a string. More...
 
static bool IsSubclass (object obj, Type super)
 Checks if the given object is a subclass of the given type. More...
 
static bool IsTypeOf (object obj, Type super)
 Checks if the given object is a type of or derives the given type. More...
 
static bool IsCompiled (CodeFragment obj)
 Checks if the given code fragment is a CompiledFragment. More...
 

Static Private Member Functions

static ConstructorInfo GetConstructor (ConstructorInfo[] constructors, Type[] paramSet, bool withCasting)
 Searches a set of constructors for an overload that accepts the given types. More...
 
static MethodInfo GetOverload (MethodInfo[] overloads, string name, Type[] argSet, bool ignoreCase, bool cast)
 Gets the MethodInfo from the given set of methods which matches the given argument set and name. More...
 

Member Function Documentation

static MethodInfo Nitro.Types.GetCallable ( Type  type)
inlinestatic

Gets the Run method on the given type.

Parameters
typeThe type to get the run method for.
Returns
The MethodInfo for the Run method if found; Null otherwise.
static ConstructorInfo Nitro.Types.GetConstructor ( Type  type,
CompiledFragment[]  args 
)
inlinestatic

Gets the constructor overload for the given type and using the given arguments.

Parameters
typeThe type to get the constructor from.
argsThe set of arguments being passed to the constructor. Used to find the right overload.
Returns
A ConstructorInfo if a matching constructor overload was found; null otherwise.
static ConstructorInfo Nitro.Types.GetConstructor ( ConstructorInfo[]  constructors,
Type[]  paramSet,
bool  withCasting 
)
inlinestaticprivate

Searches a set of constructors for an overload that accepts the given types.

Parameters
constructorsThe set of constructors to search through.
paramSetThe types of the arguments to match the overload with.
withCastingTrue if casting should be used to help find a good match.
Returns
The matching ConstructorInfo if found; null otherwise.
static MethodInfo Nitro.Types.GetOverload ( MethodInfo[]  overloads,
string  name,
Type[]  argSet 
)
inlinestatic

Gets the MethodInfo from the given set of methods which matches the given argument set and name.

Parameters
overloadsThe set of overloads to find the right overload from.
nameThe name of the method to find. Note that it is case sensitive. This is used if the method set is a full set of methods from a type.
argSetThe set of arguments to find a matching overload with.
Returns
The overload if found; null otherwise.
static MethodInfo Nitro.Types.GetOverload ( MethodInfo[]  overloads,
string  name,
Type[]  argSet,
bool  ignoreCase 
)
inlinestatic

Gets the MethodInfo from the given set of methods which matches the given argument set and name.

Parameters
overloadsThe set of overloads to find the right overload from.
nameThe name of the method to find. This is used if the method set is a full set of methods from a type.
argSetThe set of arguments to find a matching overload with.
ignoreCaseDefines if the search should ignore case on the method names or not.
Returns
The overload if found; null otherwise.
static MethodInfo Nitro.Types.GetOverload ( MethodInfo[]  overloads,
string  name,
Type[]  argSet,
bool  ignoreCase,
bool  cast 
)
inlinestaticprivate

Gets the MethodInfo from the given set of methods which matches the given argument set and name.

Parameters
overloadsThe set of overloads to find the right overload from.
nameThe name of the method to find. This is used if the method set is a full set of methods from a type.
argSetThe set of arguments to find a matching overload with.
ignoreCaseDefines if the search should ignore case on the method names or not.
castTrue if the search should allow casting when performing the match.
Returns
The overload if found; null otherwise.
static Type [] Nitro.Types.GetTypes ( CompiledFragment[]  frags)
inlinestatic

Converts a set of compiled fragments into a set of their outputted types. E.g. if a certain fragment is "a string", one of the types will be a string.

Parameters
fragsThe set of fragments to convert.
Returns
A set of types. Each one is the output type of each fragment.
static MethodInfo Nitro.Types.IsCastableTo ( Type  from,
Type  to,
out bool  isExplicit 
)
inlinestatic

Checks if one type is castable to another, reporting if it must be done explicitly or not if its possible.

Parameters
fromThe type to cast from.
toThe type to cast to.
isExplicitTrue if the cast must be done explicity.
Returns
The casting methods MethodInfo if a cast is possible at all; Null otherwise.
static bool Nitro.Types.IsCompiled ( CodeFragment  obj)
inlinestatic

Checks if the given code fragment is a CompiledFragment.

Parameters
objThe fragment to check.
Returns
True if it is a CompiledFragment; false otherwise.
static bool Nitro.Types.IsDynamic ( MemberInfo  member)
inlinestatic

Checks if the given member is from a class being compiled at the moment.

Parameters
memberThe member to check.
Returns
True if the member is from a dynamic type (one being compiled); false otherwise.
static bool Nitro.Types.IsNumeric ( Type  type)
inlinestatic

True if the given type is a numeric one (e.g. a float, int etc).

Parameters
typeThe type to check.
Returns
True if it is numeric, false otherwise.
static bool Nitro.Types.IsParams ( ParameterInfo  param)
inlinestatic

Checks if the given ParameterInfo uses the params keyword.

Parameters
paramThe parameter to check.
Returns
True if the parameter uses the params keyword; false otherwise.
static bool Nitro.Types.IsSubclass ( object  obj,
Type  super 
)
inlinestatic

Checks if the given object is a subclass of the given type.

Parameters
objThe object to check.
superThe type to compare it with.
Returns
True if the given object is a subclass; false otherwise.
static bool Nitro.Types.IsTypeOf ( object  obj,
Type  super 
)
inlinestatic

Checks if the given object is a type of or derives the given type.

Parameters
objThe object to check.
superThe type to compare it with.
Returns
True if the given object derives or is of the given type; false otherwise.
static bool Nitro.Types.IsVoid ( Type  T)
inlinestatic

Checks if the given type is either a system or nitro void.

Returns
True if it is, or if its null. False otherwise.
static Type Nitro.Types.MethodReturnType ( Type  type,
string  name 
)
inlinestatic

Gets the return type of a named method on the given type. Note that all overloads must return the same type in Nitro.

Parameters
typeThe type to look for the method on.
nameThe name of the method to look for.
Returns
The return type of the method, if it was found. Null otherwise.
static string Nitro.Types.NameWithoutNamespace ( string  typeName)
inlinestatic

Gets the name of a type without the namespace. E.g. System.Int32 becomes Int32.

Parameters
typeNameThe full typename, including the namespace.
Returns
The type name without the namespace.
static bool Nitro.Types.NoReturn ( MethodInfo  methodInfo)
inlinestatic

Checks if the given method doesn't return anything.

Parameters
methodInfoThe method to check.
Returns
True if the method has no return; false if it does.
static void Nitro.Types.OutputParameters ( CompiledFragment[]  args,
CompiledMethod  method,
NitroIL  into,
ParameterInfo[]  parameters 
)
inlinestatic

Outputs the given argument set into the given IL stream.

Parameters
argsThe compiled set of arguments to be outputted.
methodThe method that they are being used in.
intoThe IL stream to output the arguments into.
parametersThe parameter info used to correctly match the location of the parameters.
static string Nitro.Types.SetToString ( ParameterInfo[]  set)
inlinestatic

Converts the given set of parameters into a string of name:Type, seperated by commas.

Parameters
setThe set of parameters to turn into a string.
Returns
The set as a string.
static MethodOperation Nitro.Types.ToStringMethod ( CompiledMethod  method,
CompiledFragment  frag,
Type  type 
)
inlinestatic

Gets the ToString method of the given type, being called on the given fragment.

Parameters
methodThe function this operation is occuring in.
fragThe object that the ToString method is being called on.
typeThe type that fragment contains and the one that the ToString operation must be found on.
Returns
A methodOperation representing the ToString call. Throws an error if frag is null.
static CompiledFragment Nitro.Types.TryCast ( CompiledMethod  method,
CompiledFragment  frag,
Type  to 
)
inlinestatic

Attempts to generate a cast operation for the given fragment to the given type.

Parameters
methodThe method this operation is occuring in.
fragThe fragment containing the object to cast.
toThe type to cast it to if possible.
Returns
A cast operation if it is possible; throws an error otherwise.
static CompiledFragment Nitro.Types.TryCast ( CompiledMethod  method,
CompiledFragment  frag,
Type  to,
out bool  isExplicit 
)
inlinestatic

Attempts to generate a cast operation for the given fragment to the given type.

Parameters
methodThe method this operation is occuring in.
fragThe fragment containing the object to cast.
toThe type to cast it to if possible.
isExplicitTrue if the casting is explicit. False if it is implicit.
Returns
A cast operation if it is possible; throws an error otherwise.
static bool Nitro.Types.TypeSetsMatch ( Type[]  a,
Type[]  b 
)
inlinestatic

Checks if A and B match. Note that types in A can derive (inherit) types in set B.

Parameters
aThe first set to match.
bThe second set to match.
Returns
True if A and B match; false otherwise.
static bool Nitro.Types.TypeSetsMatchExactly ( Type[]  a,
Type[]  b 
)
inlinestatic

Checks if the given type sets match exactly with no inheritance allowed.

Parameters
aThe first set to match.
bThe second set to match.
Returns
True if A and B match; false otherwise.
static int Nitro.Types.WillAccept ( Type[]  args,
ParameterInfo[]  parameters,
bool  withCasting 
)
inlinestatic

Checks if the given parameter set will accept the given argument set. Used to find an overload.

Parameters
argsThe set of arguments.
parametersThe set of parameters.
withCastingTrue if casting is allowed to perform the match.
Returns
A number which represents how many casts must occur to accept (minimise when selecting an overload). -1 is returned if it cannot accept at all.