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

SizeOfParameters() private static method

private static SizeOfParameters ( string pString ) : int
pString string
return int
		private static int SizeOfParameters(string pString)
		{
			int length = pString.Length;
			int rightParenthesis = pString.LastIndexOf(')');
			if (3 <= length && pString[0] == '(' && 1 <= rightParenthesis && rightParenthesis + 1 < length)
			{
				bool ok = true;
				int index = 1;
				int stackDiff = 0;
				int count = 0;
				while (index != rightParenthesis)
				{
					switch (pString[index])
					{
						default:
						{
							ok = false;
							goto stringLoop_break;
						}

						case 'J':
						case 'D':
						{
							--stackDiff;
							goto case 'B';
						}

						case 'B':
						case 'S':
						case 'C':
						case 'I':
						case 'Z':
						case 'F':
						{
							// fall thru
							--stackDiff;
							++count;
							++index;
							continue;
						}

						case '[':
						{
							++index;
							int c = pString[index];
							while (c == '[')
							{
								++index;
								c = pString[index];
							}
							switch (c)
							{
								default:
								{
									ok = false;
									goto stringLoop_break;
								}

								case 'J':
								case 'D':
								case 'B':
								case 'S':
								case 'C':
								case 'I':
								case 'Z':
								case 'F':
								{
									--stackDiff;
									++count;
									++index;
									continue;
								}

								case 'L':
								{
									break;
								}
							}
							goto case 'L';
						}

						case 'L':
						{
							// fall thru
							// fall thru
							--stackDiff;
							++count;
							++index;
							int semicolon = pString.IndexOf(';', index);
							if (!(index + 1 <= semicolon && semicolon < rightParenthesis))
							{
								ok = false;
								goto stringLoop_break;
							}
							index = semicolon + 1;
							continue;
						}
					}
stringLoop_continue: ;
				}
stringLoop_break: ;
				if (ok)
				{
					switch (pString[rightParenthesis + 1])
					{
						default:
						{
							ok = false;
							break;
						}

						case 'J':
						case 'D':
						{
							++stackDiff;
							goto case 'B';
						}

						case 'B':
						case 'S':
						case 'C':
						case 'I':
						case 'Z':
						case 'F':
						case 'L':
						case '[':
						{
							// fall thru
							++stackDiff;
							goto case 'V';
						}

						case 'V':
						{
							// fall thru
							break;
						}
					}
					if (ok)
					{
						return ((count << 16) | (unchecked((int)(0xFFFF)) & stackDiff));
					}
				}
			}
			throw new ArgumentException("Bad parameter signature: " + pString);
		}