Ejemplo n.º 1
0
		public void Write(BinaryWriter Writer)
		{
			// i am assuming we have a valid constant pool list...
			// i dont do any error checking here except bare minimum!

			// write the number of constant pool entries
			Common.WriteWord(Writer, FMaxItems + 1);
			int count = 0;

			// goes from 1 -> constantpoolcount - 1
			while (count < FMaxItems)
			{
				ConstantPoolInfo Item = (ConstantPoolInfo)FItems[count];

				switch (Item.Tag)
				{
					case (byte)ConstantPoolInfoTag.ConstantClass:
						{
							ConstantClassInfo cc = (ConstantClassInfo)Item;
							cc.Write(Writer);

							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantString:
						{
							ConstantStringInfo cc = (ConstantStringInfo)Item;
							cc.Write(Writer);

							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantFieldref:
						{
							ConstantFieldrefInfo cc = (ConstantFieldrefInfo)Item;
							cc.Write(Writer);

							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantMethodref:
						{
							ConstantMethodrefInfo cc = (ConstantMethodrefInfo)Item;
							cc.Write(Writer);

							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantInterfaceMethodref:
						{
							ConstantInterfaceMethodrefInfo cc = (ConstantInterfaceMethodrefInfo)Item;
							cc.Write(Writer);

							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantInteger:
						{
							ConstantIntegerInfo cc = (ConstantIntegerInfo)Item;
							cc.Write(Writer);

							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantFloat:
						{
							ConstantFloatInfo cc = (ConstantFloatInfo)Item;
							cc.Write(Writer);

							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantLong:
						{
							ConstantLongInfo cc = (ConstantLongInfo)Item;
							cc.Write(Writer);

							// longs take up two entries in the pool table
							count++;
							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantDouble:
						{
							ConstantDoubleInfo cc = (ConstantDoubleInfo)Item;
							cc.Write(Writer);

							// so do doubles
							count++;
							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantNameAndType:
						{
							ConstantNameAndTypeInfo cc = (ConstantNameAndTypeInfo)Item;
							cc.Write(Writer);

							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantUtf8:
						{
							ConstantUtf8Info cc = (ConstantUtf8Info)Item;
							cc.Write(Writer);

							break;
						}

					default:
						// fail safe ?
						// BADDDDDDDDDDDDDDDDDDDDD, prolly should check/fix this
						count++;
						break;
				}

				count++;
			}
		}
Ejemplo n.º 2
0
        public TConstantPool(BinaryReader Reader)
        {
            FReader = Reader;

            FMaxItems = Common.ReadWord(FReader) - 1;
            FItems = new ArrayList();
            int count = 0;

            // goes from 1 -> constantpoolcount - 1
            while (count < FMaxItems)
            {
                byte tag = Common.ReadByte(FReader);

                switch (tag)
                {
                    case (byte)ConstantPoolInfoTag.ConstantClass:
                        {
                            ConstantClassInfo cc = new ConstantClassInfo();
                            cc.Read(tag, FReader);
                            FItems.Add(cc);
                            break;
                        }
                    case (byte)ConstantPoolInfoTag.ConstantString:
                        {
                            ConstantStringInfo cc = new ConstantStringInfo();
                            cc.Read(tag, FReader);
                            FItems.Add(cc);
                            break;
                        }
                    case (byte)ConstantPoolInfoTag.ConstantFieldref:
                        {
                            ConstantFieldrefInfo cc = new ConstantFieldrefInfo();
                            cc.Read(tag, FReader);
                            FItems.Add(cc);
                            break;
                        }
                    case (byte)ConstantPoolInfoTag.ConstantMethodref:
                        {
                            ConstantMethodrefInfo cc = new ConstantMethodrefInfo();
                            cc.Read(tag, FReader);
                            FItems.Add(cc);
                            break;
                        }
                    case (byte)ConstantPoolInfoTag.ConstantInterfaceMethodref:
                        {
                            ConstantInterfaceMethodrefInfo cc = new ConstantInterfaceMethodrefInfo();
                            cc.Read(tag, FReader);
                            FItems.Add(cc);
                            break;
                        }
                    case (byte)ConstantPoolInfoTag.ConstantInteger:
                        {
                            ConstantIntegerInfo cc = new ConstantIntegerInfo();
                            cc.Read(tag, FReader);
                            FItems.Add(cc);
                            break;
                        }
                    case (byte)ConstantPoolInfoTag.ConstantFloat:
                        {
                            ConstantFloatInfo cc = new ConstantFloatInfo();
                            cc.Read(tag, FReader);
                            FItems.Add(cc);
                            break;
                        }
                    case (byte)ConstantPoolInfoTag.ConstantLong:
                        {
                            ConstantLongInfo cc = new ConstantLongInfo();
                            cc.Read(tag, FReader);
                            FItems.Add(cc);
                            // longs take up two entries in the pool table
                            count++;
                            FItems.Add(cc);
                            break;
                        }
                    case (byte)ConstantPoolInfoTag.ConstantDouble:
                        {
                            ConstantDoubleInfo cc = new ConstantDoubleInfo();
                            cc.Read(tag, FReader);
                            FItems.Add(cc);
                            // so do doubles
                            count++;
                            FItems.Add(cc);
                            break;
                        }
                    case (byte)ConstantPoolInfoTag.ConstantNameAndType:
                        {
                            ConstantNameAndTypeInfo cc = new ConstantNameAndTypeInfo();
                            cc.Read(tag, FReader);
                            FItems.Add(cc);
                            break;
                        }
                    case (byte)ConstantPoolInfoTag.ConstantUtf8:
                        {
                            ConstantUtf8Info cc = new ConstantUtf8Info();
                            cc.Read(tag, FReader);
                            FItems.Add(cc);
                            break;
                        }

                    default:
                        // fail safe ?
                        count++;
                        break;
                }

                count++;
            }

            foreach (ConstantPoolInfo cc in FItems)
            {
                cc.Resolve(FItems);
            }
        }
Ejemplo n.º 3
0
		public TConstantPool(BinaryReader Reader)
		{
			FReader = Reader;

			FMaxItems = Common.ReadWord(FReader) - 1;
			FItems = new ArrayList();
			int count = 0;

			// goes from 1 -> constantpoolcount - 1
			while (count < FMaxItems)
			{
				byte tag = Common.ReadByte(FReader);

				switch (tag)
				{
					case (byte)ConstantPoolInfoTag.ConstantClass:
						{
							ConstantClassInfo cc = new ConstantClassInfo();
							cc.Read(tag, FReader);
							FItems.Add(cc);
							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantString:
						{
							ConstantStringInfo cc = new ConstantStringInfo();
							cc.Read(tag, FReader);
							FItems.Add(cc);
							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantFieldref:
						{
							ConstantFieldrefInfo cc = new ConstantFieldrefInfo();
							cc.Read(tag, FReader);
							FItems.Add(cc);
							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantMethodref:
						{
							ConstantMethodrefInfo cc = new ConstantMethodrefInfo();
							cc.Read(tag, FReader);
							FItems.Add(cc);
							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantInterfaceMethodref:
						{
							ConstantInterfaceMethodrefInfo cc = new ConstantInterfaceMethodrefInfo();
							cc.Read(tag, FReader);
							FItems.Add(cc);
							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantInteger:
						{
							ConstantIntegerInfo cc = new ConstantIntegerInfo();
							cc.Read(tag, FReader);
							FItems.Add(cc);
							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantFloat:
						{
							ConstantFloatInfo cc = new ConstantFloatInfo();
							cc.Read(tag, FReader);
							FItems.Add(cc);
							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantLong:
						{
							ConstantLongInfo cc = new ConstantLongInfo();
							cc.Read(tag, FReader);
							FItems.Add(cc);
							// longs take up two entries in the pool table
							count++;
							FItems.Add(cc);
							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantDouble:
						{
							ConstantDoubleInfo cc = new ConstantDoubleInfo();
							cc.Read(tag, FReader);
							FItems.Add(cc);
							// so do doubles
							count++;
							FItems.Add(cc);
							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantNameAndType:
						{
							ConstantNameAndTypeInfo cc = new ConstantNameAndTypeInfo();
							cc.Read(tag, FReader);
							FItems.Add(cc);
							break;
						}
					case (byte)ConstantPoolInfoTag.ConstantUtf8:
						{
							ConstantUtf8Info cc = new ConstantUtf8Info();
							cc.Read(tag, FReader);
							FItems.Add(cc);
							break;
						}

					default:
						// fail safe ?
						count++;
						break;
				}

				count++;
			}

			foreach (ConstantPoolInfo cc in FItems)
			{
				cc.Resolve(FItems);
			}
		}