def pop(self, index, byteCode, start, prnt): Util.printOnConsole((' '+ self.ByteCodeTable[byteCode]), prnt) return 1
def bspush(self, index, byteCode, start, prnt): #index into the biData - start+2 and length 2(for one byte) Util.printOnConsole((' '+ self.ByteCodeTable[byteCode]+' '+str((int)(Util.convertDataToPrint(self.binData, (start + 2), 2), 16))), prnt) return 2
def istore(self, index, byteCode, start, prnt): Util.printOnConsole((' '+ self.ByteCodeTable[byteCode]+' '+str((int)(Util.convertDataToPrint(self.binData, (start + 2), 2), 16))), prnt) return 2
def processExceptionHandlerInfo(self, cpCmp, start, length, prnt): start += length length = 4 startOffset = (int)(Util.convertDataToPrint(self.binData, start, length), 16) Util.printOnConsole( (' start offset (beginning of the try block), ' + str(startOffset)), prnt) start += length length = 4 bitField = (int)(Util.convertDataToPrint(self.binData, start, length), 16) stopBit = ((bitField & 0x8000) == 0x8000) if (stopBit): Util.printOnConsole((' stop bit is high'), prnt) else: Util.printOnConsole((' stop bit is low'), prnt) activeLength = (bitField & 0x7FFF) Util.printOnConsole( (' active length of the handler block, ' + str(activeLength)), prnt) start += length length = 4 handlerOffset = (int)(Util.convertDataToPrint(self.binData, start, length), 16) Util.printOnConsole(( ' handler offset in the method component (catch/finally block), ' + str(handlerOffset)), prnt) start += length length = 4 catchTypeIndex = (int)(Util.convertDataToPrint(self.binData, start, length), 16) Util.printOnConsole((' catch type index, ' + str(catchTypeIndex)), prnt) if (catchTypeIndex): Util.printOnConsole(( ' class info of the exception class caught by the exception handler, ' ), prnt) cpCmp.parseTheInfoForTheGivenIndex(catchTypeIndex) return start, length
def parseMethodInfo(self, start, length, byteCodeCount, prnt): start += length length = 2 bitField = (int)(Util.convertDataToPrint(self.binData, start, length), 16) flags = ((bitField & 0xF0) >> 4) if (0x08 == flags): Util.printOnConsole((' Method is extended method'), prnt) elif (0x04 == flags): Util.printOnConsole((' Method is abstract method'), prnt) maxStack = (bitField & 0x0F) Util.printOnConsole( (' Max stack required for the execution of this method, ' + str(maxStack)), prnt) start += length length = 2 bitField = (int)(Util.convertDataToPrint(self.binData, start, length), 16) nargs = ((bitField & 0xF0) >> 4) Util.printOnConsole(( ' Number of arguments including this pointer for virtual methods, ' + str(nargs)), prnt) maxLocals = (bitField & 0x0F) Util.printOnConsole( (' Number of locals declared by this method, ' + str(maxLocals)), prnt) Util.printOnConsole((' ByteCode, '), prnt) indx = 0 start += length while (indx < byteCodeCount): length = 2 byteCode = (int)(Util.convertDataToPrint(self.binData, start, length), 16) #print(' ', self.byteCodeTable[byteCode]) byteCodeLength = self.byteCode.execByteCode( byteCode, indx, start, prnt) indx += byteCodeLength start += byteCodeLength * 2 return start, length
def processMethod(self, prnt): self.processCP('false') Util.printOnConsole("\nMethod", prnt) self.hashMap['Method'].processMethodComp(self.hashMap['ConstantPool'], prnt)
def processDescriptor(self, prnt): self.processMethod('false') Util.printOnConsole("\nDescriptor", prnt) self.hashMap['Descriptor'].processDescriptorComp( self.hashMap['Method'], prnt)
def processCP(self, prnt): Util.printOnConsole("\nConstantPool", prnt) self.hashMap['ConstantPool'].processCPComp(prnt)