コード例 #1
0
 public override void VisitAssemblyNameReference(AssemblyNameReference reference)
 {
     m_writer.Write(".assembly extern ");
     m_writer.WriteLine(Formater.Escape(reference.Name));
     m_writer.OpenBlock();
     AssemblyDetails(reference);
     m_writer.CloseBlock();
 }
コード例 #2
0
        //FIXME: Move to ReflectionDisassembler ?
        public void DisassembleMethod(MethodDefinition method, CilWriter writer)
        {
            m_writer = writer;
            //    .method public hidebysig  specialname
            //               instance default class [mscorlib]System.IO.TextWriter get_BaseWriter ()  cil managed
            //

            // write method header
            m_writer.Write(".method ");

            //emit flags
            WriteMethodVisibility(method.Attributes);
            WriteMethodAttributes(method.Attributes);

            m_writer.WriteLine();
            m_writer.Indent();

            if (method.HasThis)
            {
                m_writer.Write("instance ");
            }

            //call convention
            WriteMethodCallingConvention(method.CallingConvention);

            //return type
            //method.ReturnType.ReturnType.Accept (m_reflectDis);
            //FIXME: another visitor for printing names (refs to methoddef/typedef/typeref etc
            m_writer.Write(Formater.Signature(method.ReturnType.ReturnType, false, true));
            m_writer.Write(method.Name);

            //( params )
            m_writer.Write(" (");
            method.Parameters.Accept(m_reflectDis);
            m_writer.Write(") ");
            //cil managed
            WriteMethodCodeType(method.ImplAttributes);
            WriteMethodManagedType(method.ImplAttributes);

            m_writer.Unindent();

            m_writer.OpenBlock();
            m_reflectDis.VisitCustomAttributeCollection(method.CustomAttributes);
            m_reflectDis.VisitSecurityDeclarationCollection(method.SecurityDeclarations);

            if (method.HasBody)
            {
                VisitMethodBody(method.Body);
            }

            m_writer.CloseBlock();
        }
コード例 #3
0
        public override void VisitTypeDefinition(TypeDefinition type)
        {
            if (type.DeclaringType != null)
            {
                return;
            }

            if (type.Namespace.Length > 0)
            {
                m_writer.Write(".namespace ");
                m_writer.WriteLine(type.Namespace);
                m_writer.OpenBlock();
            }

            if (type.MetadataToken.RID == 1)
            {
                //<Module>
                WriteTypeBody(type);
            }
            else
            {
                WriteTypeHeader(type);

                m_writer.OpenBlock();

                WriteTypeBody(type);
                VisitNestedTypeCollection(type.NestedTypes);

                m_writer.CloseBlock();

                if (type.Namespace.Length > 0)
                {
                    m_writer.CloseBlock();
                }
            }

            m_writer.WriteLine();
        }
コード例 #4
0
ファイル: CodeDisassembler.cs プロジェクト: JamesLinus/ildasm
		//FIXME: Move to ReflectionDisassembler ?
		public void DisassembleMethod (MethodDefinition method, CilWriter writer)
		{
			m_writer = writer;
			//    .method public hidebysig  specialname
			//               instance default class [mscorlib]System.IO.TextWriter get_BaseWriter ()  cil managed
			//

			// write method header
			m_writer.Write (".method ");

			//emit flags
			WriteMethodVisibility (method.Attributes);
			WriteMethodAttributes (method.Attributes);

			if(method.IsPInvokeImpl) {
				//Console.Error.WriteLine(method.PInvokeInfo);
				String module = method.PInvokeInfo.Module.Name;
				String symbol = method.PInvokeInfo.EntryPoint;
				m_writer.BaseWriter.Write("(");
				m_writer.BaseWriter.Write(String.Format("\"{0}\" as \"{1}\"", module, symbol));
				m_writer.BaseWriter.Write(")");
			}

			m_writer.WriteLine ();
			m_writer.Indent ();

			if (method.HasThis)
				m_writer.Write ("instance ");

			//call convention
			WriteMethodCallingConvention (method.CallingConvention);

			//return type
			//method.ReturnType.ReturnType.Accept (m_reflectDis);
			//FIXME: another visitor for printing names (refs to methoddef/typedef/typeref etc
			m_writer.Write (Formater.Signature (method.ReturnType.ReturnType, false, !NoAlias));
			m_writer.Write (method.Name);

			//( params )
			m_writer.BaseWriter.Write (" (");
			method.Parameters.Accept (m_reflectDis);
			m_writer.BaseWriter.Write (") ");
			//cil managed
			WriteMethodCodeType (method.ImplAttributes);
			WriteMethodManagedType (method.ImplAttributes);

			m_writer.Unindent ();

			m_writer.OpenBlock ();
			m_reflectDis.VisitCustomAttributeCollection (method.CustomAttributes);
			m_reflectDis.VisitSecurityDeclarationCollection (method.SecurityDeclarations);

			if (method.HasBody)
				VisitMethodBody (method.Body);

			m_writer.CloseBlock ();
		}