コード例 #1
0
ファイル: DynInitHelper.cs プロジェクト: terkhorn/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));
        }
コード例 #2
0
        private Expression RewriteCallSite(CallSite site, TypeGen tg, Type delegateType, out SiteInfo siteInfo)
        {
            if (!(site.Binder is IExpressionSerializable serializer))
            {
                throw new ArgumentException("Generating code from non-serializable CallSiteBinder.");
            }

            Type         siteType = site.GetType();
            FieldBuilder fb       = tg.AddStaticField(siteType, "sf" + (_id++).ToString());

            siteInfo = new SiteInfo(fb, siteType, site.Binder, delegateType);
            _siteInfos.Add(siteInfo);

            // rewrite the node...
            return(Expression.Field(null, fb));
        }
コード例 #3
0
        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);

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