当前位置: 首页>>代码示例>>C#>>正文


C# TypeReference.Write方法代码示例

本文整理汇总了C#中TypeReference.Write方法的典型用法代码示例。如果您正苦于以下问题:C# TypeReference.Write方法的具体用法?C# TypeReference.Write怎么用?C# TypeReference.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeReference的用法示例。


在下文中一共展示了TypeReference.Write方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Write

        public void Write(ModuleWriter writer)
        {
            // Create the header.
            ModuleHeader header = new ModuleHeader();

            // Populate it.

            // Store the module type.
            header.moduleType = (uint)moduleType;

            // Write the header.
            header.Write(writer);

            // Prepare the members.
            globalNamespace.PrepareSerialization();
            foreach(ScopeMember instance in genericInstances)
                instance.PrepareSerialization();

            // Prepare type referemnces.
            PrepareTypeReferences();

            // Prepare resource writing.
            PrepareResources();

            // Prepare debug information.
            DebugEmitter debugEmitter = null;
            if(debugBuild)
            {
                debugEmitter = new DebugEmitter(this);
                debugEmitter.Prepare();
                globalNamespace.PrepareDebug(debugEmitter);
            }

            // Don't allow registering members.
            writingModule = true;

            // Write the members.
            header.memberTableOffset = writer.GetPosition();
            foreach(ScopeMember member in memberTable)
            {
                // Write local members, and a pointer for the externals.
                ChelaModule memberModule = member.GetModule();
                if(memberModule == this)
                {
                    member.Write(writer);
                }
                else
                {
                    // Don't write external generic instances.
                    if(member.GetGenericInstance() != null)
                        throw new ModuleException("Write external generic instance.");

                    // Create the member reference header.
                    MemberHeader mheader = new MemberHeader();
                    mheader.memberSize = 1;
                    mheader.memberName = RegisterString(member.GetFullName()); // TODO: Use mangled name.
                    mheader.memberType = (byte)MemberHeaderType.Reference;

                    // Write the reference header and module id.
                    mheader.Write(writer);
                    writer.Write((byte)AddReference(memberModule));
                }
            }
            header.memberTableSize = writer.GetPosition() - header.memberTableOffset;

            // Write module references.
            header.moduleRefTableOffset = writer.GetPosition();
            header.moduleRefTableEntries = (uint) (referencedModules.Count + 1);

            // Write myself.
            ModuleReference modRef = new ModuleReference();
            modRef.moduleName = RegisterString(GetName());
            modRef.Write(writer);

            // Write module references.
            foreach(ChelaModule mod in referencedModules)
            {
                modRef.moduleName = RegisterString(mod.GetName());
                modRef.Write(writer);
            }

            // Write the libraries table.
            header.libTableOffset = writer.GetPosition();
            header.libTableEntries = (uint)nativeLibraries.Count;
            foreach(string libname in nativeLibraries)
                writer.Write(RegisterString(libname));

            // Write the anonymous types.
            header.anonTypeTableOffset = writer.GetPosition();
            WriteAnonType(writer);
            header.anonTypeTableSize = writer.GetPosition() - header.anonTypeTableOffset;

            // Write the type table.
            header.typeTableOffset = writer.GetPosition();
            header.typeTableEntries = (uint)typeTable.Count;
            TypeReference typeRef = new TypeReference();
            foreach(IChelaType type in typeTable)
            {
                // Write the type kind.
                if(type.IsTypeInstance())
//.........这里部分代码省略.........
开发者ID:ronsaldo,项目名称:chela,代码行数:101,代码来源:ChelaModule.cs


注:本文中的TypeReference.Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。