clojure.lang.CljCompiler.Ast.ObjExpr.EmitClosedOverFields C# (CSharp) Method

EmitClosedOverFields() protected method

protected EmitClosedOverFields ( TypeBuilder tb ) : void
tb System.Reflection.Emit.TypeBuilder
return void
        protected void EmitClosedOverFields(TypeBuilder tb)
        {
            ClosedOverFields = new List<FieldBuilder>(Closes.count());
            ClosedOverFieldsToBindingsMap = new Dictionary<FieldBuilder, LocalBinding>(Closes.count());
            ClosedOverFieldsMap = new Dictionary<LocalBinding, FieldBuilder>(Closes.count());

            // closed-overs map to instance fields.
            for (ISeq s = RT.keys(Closes); s != null; s = s.next())
            {
                LocalBinding lb = (LocalBinding)s.first();

                FieldAttributes attributes = FieldAttributes.Public;
                bool markVolatile = IsVolatile(lb);

                if (IsDefType)
                {
                    if (!IsMutable(lb))
                        attributes |= FieldAttributes.InitOnly;
                }

                Type type = lb.PrimitiveType ?? typeof(object);

                FieldBuilder fb = markVolatile
                    ? tb.DefineField(lb.Name, type, new Type[] { typeof(IsVolatile) }, Type.EmptyTypes, attributes)
                    : tb.DefineField(lb.Name, type, attributes);

                GenInterface.SetCustomAttributes(fb, GenInterface.ExtractAttributes(RT.meta(lb.Symbol)));

                ClosedOverFields.Add(fb);
                ClosedOverFieldsMap[lb] = fb;
                ClosedOverFieldsToBindingsMap[fb] = lb;
            }
        }