public int ChangeSuperClassName(string NewName) { ConstantClassInfo ClassInfo = (ConstantClassInfo)FConstantPool.Item(FSuperClass); ConstantUtf8Info UtfInfo = (ConstantUtf8Info)FConstantPool.Item(ClassInfo.NameIndex); // skip this coz we already passing the full name in //NewName = Common.NewClassName(FSuperClassName, NewName); if (UtfInfo.References <= 1) { // if this is the only reference to the name/type descriptor // we can overwrite the value UtfInfo.SetName(NewName); } else { // we have to make a new one ! UtfInfo.References--; // add a new string constant to the pool ConstantUtf8Info NewUtf = new ConstantUtf8Info(NewName); ushort NewIndex = ConstantPool.Add(NewUtf); // set the method its new name ClassInfo.NameIndex = NewIndex; NewUtf.References = 1; } FSuperClassName = ((ConstantClassInfo)FConstantPool.Item(FSuperClass)).Name; return FSuperClass; }
public int DefineConstant(IodineObject obj) { if (!ConstantPool.Contains(obj)) { ConstantPool.Add(obj); return(ConstantPool.Count - 1); } return(ConstantPool.IndexOf(obj)); }
public string ChangeClassName(string Name) { ConstantClassInfo ClassInfo = (ConstantClassInfo)FConstantPool.Item(FThisClass); ConstantUtf8Info UtfInfo = (ConstantUtf8Info)FConstantPool.Item(ClassInfo.NameIndex); // change the class name, not the directory structure Name = Common.NewClassName(ThisClassName, Name); // we have to make a new one ! UtfInfo.References--; // add a new string constant to the pool ConstantUtf8Info NewUtf = new ConstantUtf8Info(Name); ushort NewIndex = ConstantPool.Add(NewUtf); // set the method its new name ClassInfo.SetName(NewIndex, FConstantPool); NewUtf.References = 1; FThisClassName = ((ConstantClassInfo)FConstantPool.Item(FThisClass)).Name; return Name; }
public TChangeRecord ChangeFieldName(int FieldNumber, string NewName) { FieldInfo Field = (FieldInfo)FFields.Items[FieldNumber]; //FieldInfo OriginalFieldInfo = Field.Clone(); //FieldInfo NewField = null; TChangeRecord Result = null; ConstantFieldrefInfo FieldRef = null; ushort NewNameIndex; // first we need to loop through the constant pool for method // references that match our new method name for (int i = 0; i < FConstantPool.MaxItems(); i++) { if (FConstantPool.Item(i).Tag == (byte)ConstantPoolInfoTag.ConstantFieldref) { FieldRef = (ConstantFieldrefInfo)FConstantPool.Item(i); if (FieldRef.ParentClass.Name == FThisClassName && FieldRef.NameAndType.Name == Field.Name.Value && FieldRef.NameAndType.Descriptor == Field.Descriptor) { // jackpot, we found the reference! // there should be only one, so we will break and fix it up after we generate the new name break; } } FieldRef = null; } Field.Name.References--; // add a new string constant to the pool ConstantUtf8Info NewUtf = new ConstantUtf8Info(NewName); NewNameIndex = ConstantPool.Add(NewUtf); // set the method its new name Field.SetName(NewNameIndex, ConstantPool); Field.Name.References = 1; //NewField = Field.Clone(); if (FieldRef == null) return Result; if (FieldRef.NameAndType.References <= 1) { // if this is the only reference to the name/type descriptor // we can overwrite the value FieldRef.NameAndType.SetName(NewNameIndex, FConstantPool); } else { // we have to make a new one ! FieldRef.NameAndType.References--; // add a new string constant to the pool ConstantNameAndTypeInfo NewNaT = new ConstantNameAndTypeInfo(NewNameIndex, FieldRef.NameAndType.TypeIndex, FConstantPool); ushort NewIndex = ConstantPool.Add(NewNaT); // set the method its new name FieldRef.SetNameAndType(NewIndex, ConstantPool); FieldRef.NameAndType.References = 1; } return Result; }