コード例 #1
0
 public DynamicInstructionN(Type delegateType, CallSite site) {
     var methodInfo = delegateType.GetMethod("Invoke");
     _target = ReflectedCaller.Create(methodInfo);
     _targetField = site.GetType().GetField("Target");
     _site = site;
     _argCount = methodInfo.GetParameters().Length;
 }
コード例 #2
0
ファイル: DynamicInstructionN.cs プロジェクト: nickchal/pash
 public DynamicInstructionN(Type delegateType, CallSite site)
 {
     MethodInfo method = delegateType.GetMethod("Invoke");
     ParameterInfo[] parameters = method.GetParameters();
     this._target = CallInstruction.Create(method, parameters);
     this._site = site;
     this._argumentCount = parameters.Length - 1;
     this._targetDelegate = site.GetType().GetField("Target").GetValue(site);
 }
コード例 #3
0
        public DynamicInstructionN(Type delegateType, CallSite site) {
            var methodInfo = delegateType.GetMethod("Invoke");
            var parameters = methodInfo.GetParameters();

            _target = CallInstruction.Create(methodInfo, parameters);
            _targetField = site.GetType().GetField("Target");
            _site = site;
            _argCount = parameters.Length;
        }
コード例 #4
0
ファイル: DynamicInstructionN.cs プロジェクト: nlhepler/mono
        public DynamicInstructionN(Type delegateType, CallSite site) {
            var methodInfo = delegateType.GetMethod("Invoke");
            var parameters = methodInfo.GetParameters();

            // <Delegate>.Invoke is ok to target by a delegate in partial trust (SecurityException is not thrown):
            _targetInvocationInstruction = CallInstruction.Create(methodInfo, parameters);
            _site = site;
            _argumentCount = parameters.Length - 1;
            _targetDelegate = site.GetType().GetInheritedFields("Target").First().GetValue(site);
        }
コード例 #5
0
ファイル: DynInitHelper.cs プロジェクト: 101v/clojure-clr
        private Expression RewriteCallSite(CallSite site, TypeGen tg)
        {
            IExpressionSerializable serializer = site.Binder as IExpressionSerializable;
            if (serializer == null)
            {
                throw new ArgumentException("Generating code from non-serializable CallSiteBinder.");
            }

            Type siteType = site.GetType();

            FieldBuilder fb = tg.AddStaticField(siteType, "sf" + (_id++).ToString());
            Expression init = Expression.Call(siteType.GetMethod("Create"), serializer.CreateExpression());

            _fieldBuilders.Add(fb);
            _fieldInits.Add(init);

            Type t = init.Type;
            if (t.IsGenericType)
            {
                Type[] args = t.GetGenericArguments()[0].GetGenericArguments(); ;
                // skip the first one, it is the site.
                for (int k = 1; k < args.Length; k++)
                {
                    Type p = args[k];
                    //if (!p.Assembly.GetName().Name.Equals("mscorlib") && !p.Assembly.GetName().Name.Equals("Clojure"))
                    //    Console.WriteLine("Found {0}", p.ToString());
                }
            }

            // rewrite the node...
            return Expression.Field(null, fb);
        }