예제 #1
0
        internal override Type CreateType(ModuleBuilder modBuilder, string fullTypeName)
        {
            UnionGenerationHelper genHelper = new UnionGenerationHelper(modBuilder, fullTypeName,
                                                                        TypeAttributes.Public);

            TypeContainer discrType = new TypeContainer(((TypeCodeImpl)m_discriminatorType).GetClsForTypeCode(),
                                                        ((TypeCodeImpl)m_discriminatorType).GetClsAttributesForTypeCode());
            // extract covered discr range from m_members
            ArrayList coveredDiscriminatorRange = CoveredDiscriminatorRange();
            genHelper.AddDiscriminatorFieldAndProperty(discrType, coveredDiscriminatorRange);

            Hashtable cases = CollectCases();
            foreach (ElementCase elemCase in cases.Values)
            {
                genHelper.GenerateSwitchCase(elemCase.ElemType, elemCase.ElemName,
                                             elemCase.GetDiscriminatorValues());
            }

            // add rep-id Attr
            IlEmitHelper.GetSingleton().AddRepositoryIDAttribute(genHelper.Builder, m_id);

            // create the resulting type
            return genHelper.FinalizeType();
        }
예제 #2
0
 public Type EndUnionTypeDefinition(Symbol typeSymbol, UnionGenerationHelper helper) {
     Type resultType = helper.FinalizeType();
     
     // book-keeping
     m_typesInCreation.Remove(typeSymbol);
     AddCompleteTypeDefinition(typeSymbol, new CompileTimeTypeContainer(this, resultType));
     
     return resultType;            
 }