Org.Mozilla.Classfile.ClassFileWriter.CreateInitialLocals C# (CSharp) Method

CreateInitialLocals() private method

Compute the initial local variable array for the current method.
Compute the initial local variable array for the current method. Creates an array of the size of the method's max locals, regardless of the number of parameters in the method.
private CreateInitialLocals ( ) : int[]
return int[]
		private int[] CreateInitialLocals()
		{
			int[] initialLocals = new int[itsMaxLocals];
			int localsTop = 0;
			// Instance methods require the first local variable in the array
			// to be "this". However, if the method being created is a
			// constructor, aka the method is <init>, then the type of "this"
			// should be StackMapTable.UNINITIALIZED_THIS
			if ((itsCurrentMethod.GetFlags() & ACC_STATIC) == 0)
			{
				if ("<init>".Equals(itsCurrentMethod.GetName()))
				{
					initialLocals[localsTop++] = TypeInfo.UNINITIALIZED_THIS;
				}
				else
				{
					initialLocals[localsTop++] = TypeInfo.OBJECT(itsThisClassIndex);
				}
			}
			// No error checking should be necessary, sizeOfParameters does this
			string type = itsCurrentMethod.GetType();
			int lParenIndex = type.IndexOf('(');
			int rParenIndex = type.IndexOf(')');
			if (lParenIndex != 0 || rParenIndex < 0)
			{
				throw new ArgumentException("bad method type");
			}
			int start = lParenIndex + 1;
			StringBuilder paramType = new StringBuilder();
			while (start < rParenIndex)
			{
				switch (type[start])
				{
					case 'B':
					case 'C':
					case 'D':
					case 'F':
					case 'I':
					case 'J':
					case 'S':
					case 'Z':
					{
						paramType.Append(type[start]);
						++start;
						break;
					}

					case 'L':
					{
						int end = type.IndexOf(';', start) + 1;
						string name = Sharpen.Runtime.Substring(type, start, end);
						paramType.Append(name);
						start = end;
						break;
					}

					case '[':
					{
						paramType.Append('[');
						++start;
						continue;
					}
				}
				string internalType = DescriptorToInternalName(paramType.ToString());
				int typeInfo = TypeInfo.FromType(internalType, itsConstantPool);
				initialLocals[localsTop++] = typeInfo;
				if (TypeInfo.IsTwoWords(typeInfo))
				{
					localsTop++;
				}
				paramType.Length = 0;
			}
			return initialLocals;
		}