Rhino.Optimizer.Codegen.PushNumberAsObject C# (CSharp) Method

PushNumberAsObject() private method

private PushNumberAsObject ( ClassFileWriter cfw, double num ) : void
cfw Org.Mozilla.Classfile.ClassFileWriter
num double
return void
		internal virtual void PushNumberAsObject(ClassFileWriter cfw, double num)
		{
			if (num == 0.0)
			{
				if (1 / num > 0)
				{
					// +0.0
					cfw.Add(ByteCode.GETSTATIC, "org/mozilla/javascript/optimizer/OptRuntime", "zeroObj", "Ljava/lang/Double;");
				}
				else
				{
					cfw.AddPush(num);
					AddDoubleWrap(cfw);
				}
			}
			else
			{
				if (num == 1.0)
				{
					cfw.Add(ByteCode.GETSTATIC, "org/mozilla/javascript/optimizer/OptRuntime", "oneObj", "Ljava/lang/Double;");
					return;
				}
				else
				{
					if (num == -1.0)
					{
						cfw.Add(ByteCode.GETSTATIC, "org/mozilla/javascript/optimizer/OptRuntime", "minusOneObj", "Ljava/lang/Double;");
					}
					else
					{
						if (num != num)
						{
							cfw.Add(ByteCode.GETSTATIC, "org/mozilla/javascript/ScriptRuntime", "NaNobj", "Ljava/lang/Double;");
						}
						else
						{
							if (itsConstantListSize >= 2000)
							{
								// There appears to be a limit in the JVM on either the number
								// of static fields in a class or the size of the class
								// initializer. Either way, we can't have any more than 2000
								// statically init'd constants.
								cfw.AddPush(num);
								AddDoubleWrap(cfw);
							}
							else
							{
								int N = itsConstantListSize;
								int index = 0;
								if (N == 0)
								{
									itsConstantList = new double[64];
								}
								else
								{
									double[] array = itsConstantList;
									while (index != N && array[index] != num)
									{
										++index;
									}
									if (N == array.Length)
									{
										array = new double[N * 2];
										System.Array.Copy(itsConstantList, 0, array, 0, N);
										itsConstantList = array;
									}
								}
								if (index == N)
								{
									itsConstantList[N] = num;
									itsConstantListSize = N + 1;
								}
								string constantName = "_k" + index;
								string constantType = GetStaticConstantWrapperType(num);
								cfw.Add(ByteCode.GETSTATIC, mainClassName, constantName, constantType);
							}
						}
					}
				}
			}
		}