spacepaste

  1.  
  2. diff --git a/Krakatau/ssa/blockmaker.py b/Krakatau/ssa/blockmaker.py
  3. index 5326b47..5bb9e22 100644
  4. --- a/Krakatau/ssa/blockmaker.py
  5. +++ b/Krakatau/ssa/blockmaker.py
  6. @@ -10,8 +10,16 @@ from .ssa_types import slots_t, BasicBlock
  7. _charToSSAType = {'D':SSA_DOUBLE, 'F':SSA_FLOAT, 'I':SSA_INT, 'J':SSA_LONG,
  8. 'B':SSA_INT, 'C':SSA_INT, 'S':SSA_INT}
  9. def getCategory(c): return 2 if c in 'JD' else 1
  10. -
  11. -def makeDict(**kwargs): return kwargs
  12. +
  13. +class Dct(object):
  14. + def __init__(self, line=None, newstack=None, newlocals=None, jump=None):
  15. + self.line = line
  16. + self.newstack = newstack
  17. + self.jump = jump
  18. + self.newlocals = newlocals
  19. +
  20. +def makeDict(line=None, newstack=None, jump=None, newlocals=None):
  21. + return Dct(line=line, newstack=newstack, jump=jump, newlocals=newlocals)
  22. ##############################################################################
  23. def makeConstVar(parent, type_, val):
  24. @@ -435,7 +443,7 @@ def processArrayInfo(newarray_info, iNode, vals):
  25. op = iNode.instruction[0]
  26. if op == vops.NEWARRAY or op == vops.ANEWARRAY:
  27. - line = vals['line']
  28. + line = vals.line
  29. lenvar = line.params[1]
  30. assert(lenvar.type == SSA_INT)
  31. @@ -445,7 +453,7 @@ def processArrayInfo(newarray_info, iNode, vals):
  32. line.outException = None
  33. elif op == vops.ARRSTORE or op == vops.ARRSTORE_OBJ:
  34. - line = vals['line']
  35. + line = vals.line
  36. m, a, i, x = line.params
  37. if a not in newarray_info:
  38. return
  39. @@ -490,9 +498,9 @@ def fromInstruction(parent, block, newarray_info, iNode, initMap):
  40. processArrayInfo(newarray_info, iNode, vals)
  41. - line, jump = map(vals.get, ('line','jump'))
  42. - newstack = vals.get('newstack', inslots.stack)
  43. - newlocals = vals.get('newlocals', inslots.locals)
  44. + line, jump = vals.line, vals.jump
  45. + newstack = vals.newstack if vals.newstack is not None else inslots.stack
  46. + newlocals = vals.newlocals if vals.newlocals is not None else inslots.locals
  47. newmonad = line.outMonad if (line and line.outMonad) else inslots.monad
  48. outslot_norm = slots_t(monad=newmonad, locals=newlocals, stack=newstack)
  49. @@ -565,4 +573,4 @@ def makeBlocks(parent, iNodes, myclsname):
  50. for block in blocks:
  51. block.successorStates = collections.OrderedDict(block.successorStates)
  52. block.tempvars = [t for t in block.tempvars if t is not None]
  53. - return blocks
  54. \ No newline at end of file
  55. + return blocks
  56. diff --git a/benchmark.py b/benchmark.py
  57. index 1d4f933..cf0e619 100644
  58. --- a/benchmark.py
  59. +++ b/benchmark.py
  60. @@ -33,20 +33,25 @@ def makeGraph(m):
  61. def decompileClass(path=[], targets=None, outpath=None):
  62. e = Environment()
  63. + import time
  64. for part in path:
  65. e.addToPath(part)
  66. with e, Timer('warming up'):
  67. for i,target in enumerate(targets):
  68. - for _ in range(40):
  69. + for _ in range(5):
  70. c = e.getClass(target)
  71. source = javaclass.generateAST(c, makeGraph).print_()
  72. with e, Timer('testing'):
  73. + l = []
  74. for i,target in enumerate(targets):
  75. - for _ in range(200):
  76. + for _ in range(15):
  77. c = e.getClass(target)
  78. + t0 = time.time()
  79. source = javaclass.generateAST(c, makeGraph).print_()
  80. + l.append(time.time() - t0)
  81. + print l
  82. if __name__== "__main__":
  83. print 'Krakatau Copyright (C) 2012-13 Robert Grosse'
  84. @@ -64,4 +69,4 @@ if __name__== "__main__":
  85. path.extend(part.split(';'))
  86. targets = ['sun/text/normalizer/Utility']
  87. - decompileClass(path, targets, args.out)
  88. \ No newline at end of file
  89. + decompileClass(path, targets, args.out)
  90.