Org.Mozilla.Classfile.ConstantPool.AddClass C# (CSharp) Метод

AddClass() приватный Метод

private AddClass ( string className ) : short
className string
Результат short
		internal short AddClass(string className)
		{
			int theIndex = itsClassHash.Get(className, -1);
			if (theIndex == -1)
			{
				string slashed = className;
				if (className.IndexOf('.') > 0)
				{
					slashed = ClassFileWriter.GetSlashedForm(className);
					theIndex = itsClassHash.Get(slashed, -1);
					if (theIndex != -1)
					{
						itsClassHash.Put(className, theIndex);
					}
				}
				if (theIndex == -1)
				{
					int utf8Index = AddUtf8(slashed);
					Ensure(3);
					itsPool[itsTop++] = CONSTANT_Class;
					itsTop = ClassFileWriter.PutInt16(utf8Index, itsPool, itsTop);
					theIndex = itsTopIndex++;
					itsClassHash.Put(slashed, theIndex);
					if (className != slashed)
					{
						itsClassHash.Put(className, theIndex);
					}
				}
			}
			SetConstantData(theIndex, className);
			itsPoolTypes.Put(theIndex, CONSTANT_Class);
			return (short)theIndex;
		}

Usage Example

Пример #1
0
		/// <summary>Construct a ClassFileWriter for a class.</summary>
		/// <remarks>Construct a ClassFileWriter for a class.</remarks>
		/// <param name="className">
		/// the name of the class to write, including
		/// full package qualification.
		/// </param>
		/// <param name="superClassName">
		/// the name of the superclass of the class
		/// to write, including full package qualification.
		/// </param>
		/// <param name="sourceFileName">
		/// the name of the source file to use for
		/// producing debug information, or null if debug information
		/// is not desired
		/// </param>
		public ClassFileWriter(string className, string superClassName, string sourceFileName)
		{
			generatedClassName = className;
			itsConstantPool = new ConstantPool(this);
			itsThisClassIndex = itsConstantPool.AddClass(className);
			itsSuperClassIndex = itsConstantPool.AddClass(superClassName);
			if (sourceFileName != null)
			{
				itsSourceFileNameIndex = itsConstantPool.AddUtf8(sourceFileName);
			}
			// All "new" implementations are supposed to output ACC_SUPER as a
			// class flag. This is specified in the first JVM spec, so it should
			// be old enough that it's okay to always set it.
			itsFlags = ACC_PUBLIC | ACC_SUPER;
		}
All Usage Examples Of Org.Mozilla.Classfile.ConstantPool::AddClass