예제 #1
0
        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;
        }
예제 #2
0
 public static void Load(this ILGenerator gen, IILPointer pointer)
 {
     if (pointer == null)
     {
         pointer = ILPointer.Null;
     }
     pointer.Load(gen);
 }
예제 #3
0
 public static ILNegatePointer Negate(this IILPointer value)
 {
     if (value == null)
     {
         throw new ArgumentNullException(nameof(value));
     }
     return(new ILNegatePointer(value));
 }
예제 #4
0
        public ILNullablePointer(IILPointer pointer)
        {
            if (pointer.Type == null)
            {
                throw new NotSupportedException("The pointer does not have a well defined pointer type");
            }

            _pointer = pointer;
        }
예제 #5
0
 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");
     }
 }
예제 #6
0
        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());
        }
예제 #7
0
        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);
        }
예제 #8
0
        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));
        }
예제 #9
0
        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));
        }
예제 #10
0
        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));
        }
예제 #11
0
 public ILCastPointer(IILPointer pointer, Type toType)
 {
     _pointer = pointer;
     _toType  = toType;
 }
예제 #12
0
 public ILArrayElementVariable(IILPointer array, int index)
 {
     _array = array;
     _index = index;
     Type   = GetTypeFrom(array);
 }
예제 #13
0
 public ILNegatePointer(IILPointer value)
 {
     _value = value;
 }
예제 #14
0
 public ILEqualPointer(IILPointer left, IILPointer right)
 {
     _left  = left;
     _right = right;
 }
예제 #15
0
 public static void LoadAddress(this ILGenerator gen, IILPointer pointer)
 {
     pointer.LoadAddress(gen);
 }