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


C# ClassFile.RemoveUnusedFields方法代码示例

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


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

示例1: GetTypeWrapperCompilerHook

		private TypeWrapper GetTypeWrapperCompilerHook(string name)
		{
			RemapperTypeWrapper rtw;
			if(remapped.TryGetValue(name, out rtw))
			{
				return rtw;
			}
			else
			{
				ClassItem classdef;
				if(classes.TryGetValue(name, out classdef))
				{
					classes.Remove(name);
					ClassFile f;
					try
					{
						ClassFileParseOptions cfp = ClassFileParseOptions.LocalVariableTable;
						if(this.EmitStackTraceInfo)
						{
							cfp |= ClassFileParseOptions.LineNumberTable;
						}
						f = new ClassFile(classdef.data, 0, classdef.data.Length, name, cfp);
					}
					catch(ClassFormatError x)
					{
						StaticCompiler.IssueMessage(options, Message.ClassFormatError, name, x.Message);
						return null;
					}
					if(options.removeUnusedFields)
					{
						f.RemoveUnusedFields();
					}
					if(f.IsPublic && options.privatePackages != null)
					{
						foreach(string p in options.privatePackages)
						{
							if(f.Name.StartsWith(p))
							{
								f.SetInternal();
								break;
							}
						}
					}
					if(f.IsPublic && options.publicPackages != null)
					{
						bool found = false;
						foreach(string package in options.publicPackages)
						{
							if(f.Name.StartsWith(package))
							{
								found = true;
								break;
							}
						}
						if(!found)
						{
							f.SetInternal();
						}
					}
					if(!f.IsInterface
						&& !f.IsAbstract
						&& !f.IsPublic
						&& !f.IsInternal
						&& !f.IsFinal
						&& !baseClasses.ContainsKey(f.Name)
						&& !options.targetIsModule
						&& options.sharedclassloader == null)
					{
						f.SetEffectivelyFinal();
					}
					if(f.SourceFileAttribute != null)
					{
						if(classdef.path != null)
						{
							string sourceFile = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(classdef.path), f.SourceFileAttribute));
							if(File.Exists(sourceFile))
							{
								f.SourcePath = sourceFile;
							}
						}
						if(f.SourcePath == null)
						{
							if (options.sourcepath != null)
							{
								string package = f.Name;
								int index = package.LastIndexOf('.');
								package = index == -1 ? "" : package.Substring(0, index).Replace('.', '/');
								f.SourcePath = Path.GetFullPath(Path.Combine(options.sourcepath + "/" + package, f.SourceFileAttribute));
							}
							else
							{
								f.SourcePath = f.SourceFileAttribute;
							}
						}
					}
					try
					{
						TypeWrapper type = DefineClass(f, null);
						if(f.IKVMAssemblyAttribute != null)
						{
//.........这里部分代码省略.........
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:101,代码来源:CompilerClassLoader.cs

示例2: GetTypeWrapperCompilerHook

 private TypeWrapper GetTypeWrapperCompilerHook(string name)
 {
     TypeWrapper type = null;
     if(type == null)
     {
         if(remapped.TryGetValue(name, out type))
         {
             return type;
         }
         byte[] classdef;
         if(classes.TryGetValue(name, out classdef))
         {
             classes.Remove(name);
             ClassFile f;
             try
             {
                 ClassFileParseOptions cfp = ClassFileParseOptions.LocalVariableTable;
                 if(this.EmitStackTraceInfo)
                 {
                     cfp |= ClassFileParseOptions.LineNumberTable;
                 }
                 f = new ClassFile(classdef, 0, classdef.Length, name, cfp);
             }
             catch(ClassFormatError x)
             {
                 StaticCompiler.IssueMessage(options, Message.ClassFormatError, name, x.Message);
                 return null;
             }
             if(options.removeUnusedFields)
             {
                 f.RemoveUnusedFields();
             }
             if(f.IsPublic && options.privatePackages != null)
             {
                 foreach(string p in options.privatePackages)
                 {
                     if(f.Name.StartsWith(p))
                     {
                         f.SetInternal();
                         break;
                     }
                 }
             }
             if(f.IsPublic && options.publicPackages != null)
             {
                 bool found = false;
                 foreach(string package in options.publicPackages)
                 {
                     if(f.Name.StartsWith(package))
                     {
                         found = true;
                         break;
                     }
                 }
                 if(!found)
                 {
                     f.SetInternal();
                 }
             }
             if(!f.IsInterface
                 && !f.IsAbstract
                 && !f.IsPublic
                 && !f.IsInternal
                 && !f.IsFinal
                 && !baseClasses.ContainsKey(f.Name)
                 && !options.targetIsModule
                 && options.sharedclassloader == null)
             {
                 f.SetEffectivelyFinal();
             }
             try
             {
                 type = DefineClass(f, null);
                 if(f.IKVMAssemblyAttribute != null)
                 {
                     importedStubTypes.Add(f.Name, type);
                 }
             }
             catch (ClassFormatError x)
             {
                 StaticCompiler.IssueMessage(options, Message.ClassFormatError, name, x.Message);
                 return null;
             }
             catch (IllegalAccessError x)
             {
                 StaticCompiler.IssueMessage(options, Message.IllegalAccessError, name, x.Message);
                 return null;
             }
             catch (VerifyError x)
             {
                 StaticCompiler.IssueMessage(options, Message.VerificationError, name, x.Message);
                 return null;
             }
             catch (NoClassDefFoundError x)
             {
                 StaticCompiler.IssueMessage(options, Message.NoClassDefFoundError, name, x.Message);
                 return null;
             }
             catch (RetargetableJavaException x)
             {
//.........这里部分代码省略.........
开发者ID:badlogic,项目名称:ikvm-monotouch,代码行数:101,代码来源:CompilerClassLoader.cs

示例3: GetTypeWrapperCompilerHook

		private TypeWrapper GetTypeWrapperCompilerHook(string name)
		{
			RemapperTypeWrapper rtw;
			if(remapped.TryGetValue(name, out rtw))
			{
				return rtw;
			}
			else
			{
				Jar.Item itemRef;
				if(classes.TryGetValue(name, out itemRef))
				{
					classes.Remove(name);
					ClassFile f;
					try
					{
						byte[] buf = itemRef.GetData();
						f = new ClassFile(buf, 0, buf.Length, name, ClassFileParseOptions, null);
					}
					catch(ClassFormatError x)
					{
						StaticCompiler.SuppressWarning(options, Message.ClassNotFound, name);
						StaticCompiler.IssueMessage(options, Message.ClassFormatError, name, x.Message);
						return null;
					}
					if(f.Name != name)
					{
						StaticCompiler.SuppressWarning(options, Message.ClassNotFound, name);
						StaticCompiler.IssueMessage(options, Message.WrongClassName, name, f.Name);
						return null;
					}
					if(options.removeUnusedFields)
					{
						f.RemoveUnusedFields();
					}
					if(f.IsPublic && options.privatePackages != null)
					{
						foreach(string p in options.privatePackages)
						{
							if(f.Name.StartsWith(p))
							{
								f.SetInternal();
								break;
							}
						}
					}
					if(f.IsPublic && options.publicPackages != null)
					{
						bool found = false;
						foreach(string package in options.publicPackages)
						{
							if(f.Name.StartsWith(package))
							{
								found = true;
								break;
							}
						}
						if(!found)
						{
							f.SetInternal();
						}
					}
					if(f.SourceFileAttribute != null)
					{
						FileInfo path = itemRef.Path;
						if(path != null)
						{
							string sourceFile = Path.GetFullPath(Path.Combine(path.DirectoryName, f.SourceFileAttribute));
							if(File.Exists(sourceFile))
							{
								f.SourcePath = sourceFile;
							}
						}
						if(f.SourcePath == null)
						{
							if (options.sourcepath != null)
							{
								string package = f.Name;
								int index = package.LastIndexOf('.');
								package = index == -1 ? "" : package.Substring(0, index).Replace('.', '/');
								f.SourcePath = Path.GetFullPath(Path.Combine(options.sourcepath + "/" + package, f.SourceFileAttribute));
							}
							else
							{
								f.SourcePath = f.SourceFileAttribute;
							}
						}
					}
					try
					{
						TypeWrapper tw = DefineClass(f, null);
						// we successfully created the type, so we don't need to include the class as a resource
						if (options.nojarstubs)
						{
							itemRef.Remove();
						}
						else
						{
							itemRef.MarkAsStub();
						}
//.........这里部分代码省略.........
开发者ID:Semogj,项目名称:ikvm-fork,代码行数:101,代码来源:CompilerClassLoader.cs

示例4: GetTypeWrapperCompilerHook

 private TypeWrapper GetTypeWrapperCompilerHook(string name)
 {
     RemapperTypeWrapper rtw;
     if(remapped.TryGetValue(name, out rtw))
     {
         return rtw;
     }
     else
     {
         JarItemReference itemRef;
         if(classes.TryGetValue(name, out itemRef))
         {
             classes.Remove(name);
             JarItem classdef = itemRef.Jar.Items[itemRef.Index];
             ClassFile f;
             try
             {
                 ClassFileParseOptions cfp = ClassFileParseOptions.LocalVariableTable;
                 if(this.EmitStackTraceInfo)
                 {
                     cfp |= ClassFileParseOptions.LineNumberTable;
                 }
                 f = new ClassFile(classdef.data, 0, classdef.data.Length, name, cfp);
             }
             catch(ClassFormatError x)
             {
                 StaticCompiler.SuppressWarning(options, Message.ClassNotFound, name);
                 StaticCompiler.IssueMessage(options, Message.ClassFormatError, name, x.Message);
                 return null;
             }
             if(f.Name != name)
             {
                 StaticCompiler.SuppressWarning(options, Message.ClassNotFound, name);
                 StaticCompiler.IssueMessage(options, Message.WrongClassName, name, f.Name);
                 return null;
             }
             if(options.removeUnusedFields)
             {
                 f.RemoveUnusedFields();
             }
             if(f.IsPublic && options.privatePackages != null)
             {
                 foreach(string p in options.privatePackages)
                 {
                     if(f.Name.StartsWith(p))
                     {
                         f.SetInternal();
                         break;
                     }
                 }
             }
             if(f.IsPublic && options.publicPackages != null)
             {
                 bool found = false;
                 foreach(string package in options.publicPackages)
                 {
                     if(f.Name.StartsWith(package))
                     {
                         found = true;
                         break;
                     }
                 }
                 if(!found)
                 {
                     f.SetInternal();
                 }
             }
             if(!f.IsInterface
                 && !f.IsAbstract
                 && !f.IsPublic
                 && !f.IsInternal
                 && !f.IsFinal
                 && !baseClasses.ContainsKey(f.Name)
                 && !options.targetIsModule
                 && options.sharedclassloader == null)
             {
                 f.SetEffectivelyFinal();
             }
             if(f.SourceFileAttribute != null)
             {
                 if(classdef.path != null)
                 {
                     string sourceFile = Path.GetFullPath(Path.Combine(classdef.path.DirectoryName, f.SourceFileAttribute));
                     if(File.Exists(sourceFile))
                     {
                         f.SourcePath = sourceFile;
                     }
                 }
                 if(f.SourcePath == null)
                 {
                     if (options.sourcepath != null)
                     {
                         string package = f.Name;
                         int index = package.LastIndexOf('.');
                         package = index == -1 ? "" : package.Substring(0, index).Replace('.', '/');
                         f.SourcePath = Path.GetFullPath(Path.Combine(options.sourcepath + "/" + package, f.SourceFileAttribute));
                     }
                     else
                     {
                         f.SourcePath = f.SourceFileAttribute;
//.........这里部分代码省略.........
开发者ID:kenasogoo,项目名称:ikvm-fork,代码行数:101,代码来源:CompilerClassLoader.cs


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