Ejemplo n.º 1
0
		public static Dictionary<string,List<ConstantPool>> getDictionary_byType(this  List<ConstantPool> constantsPool, Java_Method method)		
		{
			var usedInMethod = method.uniqueTargetIndexes();
			//show.info(usedInMethod);
			var mappedByIndex = constantsPool.getDictionary_byIndex();
			//show.info(mappedByIndex); 
			var dictionary = new Dictionary<string,List<ConstantPool>>();
			foreach(var index in usedInMethod)
			{
				if (mappedByIndex.hasKey(index))
				{
					var constantPool = mappedByIndex[index];
					dictionary.add(constantPool.Type, constantPool);
				}
			}
			return dictionary;
		}					
Ejemplo n.º 2
0
		public static Dictionary<string,List<ConstantPool>> getDictionary_byType(this  List<ConstantPool> constantsPool)
		{
			var dictionary = new Dictionary<string,List<ConstantPool>>();
			foreach(var item in constantsPool)								
				dictionary.add(item.Type, item);			
			return dictionary;
		} 
Ejemplo n.º 3
0
		public static Dictionary<int,List<Java_Instruction>> getConstantsPoolUsage_byIndex_WithLineNumbers(this Java_Method method)
		{
			var dictionary = new Dictionary<int,List<Java_Instruction>>(); 
			foreach(var instruction in method.Instructions)	 						
				if(instruction.Target_Index >0)
				dictionary.add(instruction.Target_Index, instruction);			
			return dictionary;
		} 
Ejemplo n.º 4
0
		public static List<ConstantPool> getConstantPoolEntries(this object classFile)
		{
			var constantsPool = new List<ConstantPool>();
			
			var constantPoolRaw = new Dictionary<int,object>();
			var constantPool =  (IEnumerable)classFile.field("constantpool");  
			if (constantPool.isNull())
				"in getConstantPoolEntries , classFile.field(\"constantpool\") was null".error();
			else
			{;
				var index = 0;
				foreach(var constant in constantPool)
					constantPoolRaw.add(index++, constant); 
				
			//var constantPoolValues = new Dictionary<int,string>();	 
		//	var stillToMap = new List<object>();
				for(int i=0; i < constantPoolRaw.size() ; i++)
				{
					var currentItem = constantPoolRaw[i];
					var currentItemType = currentItem.str();
					switch(currentItemType)
					{
						case "IKVM.Internal.ClassFile+ConstantPoolItemClass":											
							constantsPool.add_Entry(i, currentItemType.remove("IKVM.Internal.ClassFile+ConstantPoolItem"), currentItem.prop("Name").str());						
							break;
						case "IKVM.Internal.ClassFile+ConstantPoolItemMethodref":											
							constantsPool.add_Entry(i,currentItemType.remove("IKVM.Internal.ClassFile+ConstantPoolItem"), 
													"{0}.{1}{2}".format(currentItem.prop("Class"),
													   	 				   currentItem.prop("Name"),
													   	 				   currentItem.prop("Signature")));									
							break;												   	 				   
						case "IKVM.Internal.ClassFile+ConstantPoolItemInterfaceMethodref": 
							constantsPool.add_Entry(i,currentItemType.remove("IKVM.Internal.ClassFile+ConstantPoolItem"),
													"{0}.{1}{2}".format(currentItem.prop("Class"),
													   	 				   currentItem.prop("Name"),
													   	 				   currentItem.prop("Signature")));									
							break;	
						case "IKVM.Internal.ClassFile+ConstantPoolItemFieldref":																		
							constantsPool.add_Entry(i,currentItemType.remove("IKVM.Internal.ClassFile+ConstantPoolItem"), 
													"{0}.{1} : {2}".format(currentItem.prop("Class"),
													   	 				   currentItem.prop("Name"),
													   	 				   currentItem.prop("Signature")));									
							break;
						case "IKVM.Internal.ClassFile+ConstantPoolItemNameAndType":	 // skip this one since don;t know what they point to
							//constantPoolValues.Add(i,"IKVM.Internal.ClassFile+ConstantPoolItemNameAndType");	
							break; 
						case "IKVM.Internal.ClassFile+ConstantPoolItemString":
						case "IKVM.Internal.ClassFile+ConstantPoolItemInteger":
						case "IKVM.Internal.ClassFile+ConstantPoolItemFloat":
						case "IKVM.Internal.ClassFile+ConstantPoolItemDouble": 
						case "IKVM.Internal.ClassFile+ConstantPoolItemLong":
							var value = currentItem.prop("Value").str();
							value = value.base64Encode();//HACK to deal with BUG in .NET Serialization and Deserialization (to reseatch further)
							constantsPool.add_Entry(i,currentItemType.remove("IKVM.Internal.ClassFile+ConstantPoolItem"),value, true);
							break;					
						case "[null value]":
							//constantsPool.add_Entry(i,"[null value]", null);						
							break; 
						default:
							"Unsupported constantPoll type: {0}".error(currentItem.str());
							break;
					}		
				}
			}
			return constantsPool;	
		}