Inheritance: IlExpression
Esempio n. 1
0
        public int StaticCall(MethodInfo method, params int[] arguments)
        {
            var call = new IlCallStatic(method, arguments.Select(a => _expressions[a]).ToArray());

            _expressions.Add(call);
            return(_expressions.Count - 1);
        }
Esempio n. 2
0
        public int NewObject(Type type)
        {
            var ctor = type.GetConstructor(new Type[] {});

            // ReSharper disable once PossibleNullReferenceException
            if (ctor != null && ctor.GetMethodBody().GetILAsByteArray().Length <= 8)
            {
                var @new = new IlNew(type);
                _expressions.Add(@new);
            }
            else
            {
                var typeExp = Constant(type);
                var t       = _expressions[typeExp]; //we need the type as a constant so we can load it in IlNew
                var method  = typeof(TypeEx).GetMethod(nameof(TypeEx.GetEmptyObject));
                var call    = new IlCallStatic(method, t);
                _expressions.Add(call);
            }

            return(_expressions.Count - 1);
        }