コード例 #1
0
ファイル: EmitVisitorPhase1.cs プロジェクト: Sullux/tws
        public override void Visit(AssemblyDefinition assemblyDefinition)
        {
            foreach (var xAsmRef in assemblyDefinition.AssemblyReferences)
            {
                mAssembly.AssemblyReferences.Add(new MCM.AssemblyReference { Name = mHostEnvironment.NameTable.GetNameFor(xAsmRef.Name) });
            }

            // root namespace
            mAssembly.UnitNamespaceRoot = new MCM.RootUnitNamespace()
            {
                Unit = mAssembly
            };
            var xModClass = new MCM.NamespaceTypeDefinition
            {
                ContainingUnitNamespace = mAssembly.UnitNamespaceRoot,
                InternFactory = mHostEnvironment.InternFactory,
                IsClass = true,
                Name = mHostEnvironment.NameTable.GetNameFor("<Module>")
            };
            mAssembly.AllTypes.Add(xModClass);
            mNamespaces.Push((MCM.UnitNamespace)mAssembly.UnitNamespaceRoot);

            base.Visit(assemblyDefinition);
        }
コード例 #2
0
ファイル: EmitVisitorPhase1.cs プロジェクト: Sullux/tws
 public override void Visit(ClassDefinition theClass)
 {
     var xCurNamespace = mNamespaces.Peek();
     MCM.TypeDefinition xClass;
     if (mTypeStack.Count > 0)
     {
         var xNestedClass = new MCM.NestedTypeDefinition
         {
             ContainingTypeDefinition = mTypeStack.Peek(),
             InternFactory = mHostEnvironment.InternFactory,
             IsClass = true,
             Name = mHostEnvironment.NameTable.GetNameFor(theClass.Name)
         };
         xClass = xNestedClass;
         mTypeStack.Peek().NestedTypes.Add(xNestedClass);
     }
     else
     {
         var xNamespaceClass = new MCM.NamespaceTypeDefinition()
         {
             ContainingUnitNamespace = xCurNamespace,
             InternFactory = mHostEnvironment.InternFactory,
             IsClass = true,
             Name = mHostEnvironment.NameTable.GetNameFor(theClass.Name)
         };
         xCurNamespace.Members.Add(xNamespaceClass);
         xClass = xNamespaceClass;
     }
     Types.Add(theClass, xClass);
     mAssembly.AllTypes.Add(xClass);
     mTypeStack.Push(xClass);
     try
     {
         base.Visit(theClass);
     }
     finally
     {
         mTypeStack.Pop();
     }
 }