public ILCallMethodSnippet(ILPointer instance, MethodInfo method, params ILPointer[] parameters) { if (instance == null && !method.IsStatic) { throw new ArgumentException("Instance must be provided for instance methods"); } if (instance != null && method.IsStatic) { throw new ArgumentException("Static method may not be invoked with an instance"); } if (!(method is System.Reflection.Emit.MethodBuilder)) { _methodParameters = method.GetParameters(); if (_methodParameters.Length < parameters.Length) { throw new ArgumentException("The parameter length supplied is greater than the method supports"); } } _instance = instance; _method = method; _parameters = parameters; ReturnType = method.ReturnType; }
public static void Load(this ILGenerator gen, IILPointer pointer) { if (pointer == null) { pointer = ILPointer.Null; } pointer.Load(gen); }
public static ILNegatePointer Negate(this IILPointer value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } return(new ILNegatePointer(value)); }
public ILNullablePointer(IILPointer pointer) { if (pointer.Type == null) { throw new NotSupportedException("The pointer does not have a well defined pointer type"); } _pointer = pointer; }
public ILAddPointer(IILPointer left, IILPointer right) { _left = left ?? throw new ArgumentNullException(nameof(left)); _right = right ?? throw new ArgumentNullException(nameof(right)); if (left.Type != right.Type) { throw new ArgumentException("The types between the values doesn't match"); } }
private static Type GetTypeFrom(IILPointer array) { var type = array.Type; if (!type.IsArray) { throw new ArgumentException("The supplied type must be an array, type was " + type.FullName); } return(type.GetElementType()); }
public static void Set(this ILGenerator gen, IILVariable variable, IILPointer value) { if (value == null) { value = ILPointer.Null; } variable.PreSet(gen); value.Load(gen); variable.Set(gen); }
public static ILEqualPointer Equal(this IILPointer left, ILPointer right) { if (left == null) { left = ILPointer.Null; } if (right == null) { right = ILPointer.Null; } return(new ILEqualPointer(left, right)); }
public static ILAddPointer Add(this IILPointer left, ILPointer right) { if (left == null) { throw new ArgumentNullException(nameof(left)); } if (right == null) { throw new ArgumentNullException(nameof(right)); } return(new ILAddPointer(left, right)); }
public static ILArrayElementVariable ElementAt(this IILPointer array, int index) { if (array == null) { throw new ArgumentNullException(nameof(array)); } if (index < 0) { throw new IndexOutOfRangeException($"The index {index} must be a positive integer."); } return(new ILArrayElementVariable(array, index)); }
public ILCastPointer(IILPointer pointer, Type toType) { _pointer = pointer; _toType = toType; }
public ILArrayElementVariable(IILPointer array, int index) { _array = array; _index = index; Type = GetTypeFrom(array); }
public ILNegatePointer(IILPointer value) { _value = value; }
public ILEqualPointer(IILPointer left, IILPointer right) { _left = left; _right = right; }
public static void LoadAddress(this ILGenerator gen, IILPointer pointer) { pointer.LoadAddress(gen); }