SetInternal() private method

private SetInternal ( ) : void
return void
		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)
						{
							importedStubTypes.Add(f.Name, type);
						}
						return 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)
					{
						StaticCompiler.IssueMessage(options, Message.GenericUnableToCompileError, name, x.GetType().Name, x.Message);
						return null;
					}
				}
				else
				{
					return null;
				}
			}
		}
 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)
             {
                 StaticCompiler.IssueMessage(options, Message.GenericUnableToCompileError, name, x.GetType().Name, x.Message);
                 return null;
             }
         }
     }
     return type;
 }
示例#3
0
		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();
						}
						int pos = f.Name.LastIndexOf('.');
						if (pos != -1)
						{
							string manifestJar = options.IsClassesJar(itemRef.Jar) ? null : itemRef.Jar.Name;
							packages.DefinePackage(f.Name.Substring(0, pos), manifestJar);
						}
						return tw;
					}
					catch (ClassFormatError x)
					{
						StaticCompiler.IssueMessage(options, Message.ClassFormatError, name, x.Message);
					}
					catch (IllegalAccessError x)
					{
						StaticCompiler.IssueMessage(options, Message.IllegalAccessError, name, x.Message);
					}
					catch (VerifyError x)
					{
						StaticCompiler.IssueMessage(options, Message.VerificationError, name, x.Message);
					}
					catch (NoClassDefFoundError x)
					{
						if ((options.codegenoptions & CodeGenOptions.DisableDynamicBinding) != 0)
						{
							StaticCompiler.IssueMessage(options, Message.NoClassDefFoundError, name, x.Message);
						}
						StaticCompiler.IssueMessage(options, Message.ClassNotFound, x.Message);
					}
					catch (RetargetableJavaException x)
					{
						StaticCompiler.IssueMessage(options, Message.GenericUnableToCompileError, name, x.GetType().Name, x.Message);
					}
					StaticCompiler.SuppressWarning(options, Message.ClassNotFound, name);
					return null;
				}
				else
				{
					return null;
				}
			}
		}
 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;
                     }
                 }
             }
             try
             {
                 TypeWrapper tw = DefineClass(f, null);
                 // we successfully created the type, so we don't need to include the class as a resource
                 itemRef.Jar.Items[itemRef.Index] = options.nojarstubs
                     ? new JarItem()	// null entry
                     : new JarItem(itemRef.Jar.Items[itemRef.Index].zipEntry, null, null); // create a stub class pseudo resource
                 return tw;
             }
             catch (ClassFormatError x)
             {
                 StaticCompiler.IssueMessage(options, Message.ClassFormatError, name, x.Message);
             }
             catch (IllegalAccessError x)
             {
                 StaticCompiler.IssueMessage(options, Message.IllegalAccessError, name, x.Message);
             }
             catch (VerifyError x)
             {
                 StaticCompiler.IssueMessage(options, Message.VerificationError, name, x.Message);
             }
             catch (NoClassDefFoundError x)
             {
                 if ((options.codegenoptions & CodeGenOptions.DisableDynamicBinding) != 0)
                 {
                     StaticCompiler.IssueMessage(options, Message.NoClassDefFoundError, name, x.Message);
                 }
                 StaticCompiler.IssueMessage(options, Message.ClassNotFound, x.Message);
             }
             catch (RetargetableJavaException x)
             {
                 StaticCompiler.IssueMessage(options, Message.GenericUnableToCompileError, name, x.GetType().Name, x.Message);
             }
             StaticCompiler.SuppressWarning(options, Message.ClassNotFound, name);
             return null;
         }
         else
         {
             return null;
         }
     }
 }