JavaByteCodeProcessor.st
branchdevelopment
changeset 2695 11ef104a9971
parent 2429 ebece4dcaab9
child 2711 a00302fe5083
equal deleted inserted replaced
2694:73e08423c72b 2695:11ef104a9971
    50      of one of the above copright owners. For exact set of such code,
    50      of one of the above copright owners. For exact set of such code,
    51      see the differences between this version and version stx:libjava
    51      see the differences between this version and version stx:libjava
    52      as of 1.9.2010
    52      as of 1.9.2010
    53 
    53 
    54 "
    54 "
       
    55 !
       
    56 
       
    57 documentation
       
    58 "
       
    59     Basic class to process Java bytecode. Subclasses must implement
       
    60     all callback methods that handle individual instructions.
       
    61 
       
    62     Subclass `JavaByteCodeProcessorAdaptor` if you want to so somethinf
       
    63     special for some instructions and don't need to bother with rest
       
    64     of them.
       
    65 
       
    66     [author:]
       
    67         Jan Vrany <jan.vrany@fit.cvut.cz>
       
    68 
       
    69     [instance variables:]
       
    70 
       
    71     [class variables:]
       
    72 
       
    73     [see also:]
       
    74         JavaByteCodeProcessorAdaptor
       
    75 
       
    76 
       
    77 "
    55 ! !
    78 ! !
    56 
       
    57 
    79 
    58 !JavaByteCodeProcessor class methodsFor:'initialization'!
    80 !JavaByteCodeProcessor class methodsFor:'initialization'!
    59 
    81 
    60 initialize
    82 initialize
    61     OpSwitchTable := Array new: 256.
    83     OpSwitchTable := Array new: 256.
   270     "Created: / 17-03-2011 / 14:56:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
   292     "Created: / 17-03-2011 / 14:56:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
   271     "Modified: / 17-03-2011 / 16:43:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
   293     "Modified: / 17-03-2011 / 16:43:17 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
   272     "Modified: / 21-03-2011 / 20:23:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   294     "Modified: / 21-03-2011 / 20:23:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   273 ! !
   295 ! !
   274 
   296 
   275 
       
   276 !JavaByteCodeProcessor class methodsFor:'accessing'!
   297 !JavaByteCodeProcessor class methodsFor:'accessing'!
   277 
   298 
   278 verbose: bool
   299 verbose: bool
   279 Verbose := bool.
   300 Verbose := bool.
   280 
   301 
   281     "Created: / 21-03-2011 / 18:32:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
   302     "Created: / 21-03-2011 / 18:32:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
   282 ! !
   303 ! !
   283 
       
   284 
   304 
   285 !JavaByteCodeProcessor class methodsFor:'private-logging'!
   305 !JavaByteCodeProcessor class methodsFor:'private-logging'!
   286 
   306 
   287 log: aMessage 
   307 log: aMessage 
   288 Verbose ifTrue: [
   308 Verbose ifTrue: [
   289     ('JAVA [info]: ' , aMessage) infoPrintCR.].
   309     ('JAVA [info]: ' , aMessage) infoPrintCR.].
   290 
   310 
   291     "Created: / 17-03-2011 / 14:59:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
   311     "Created: / 17-03-2011 / 14:59:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
   292 ! !
   312 ! !
   293 
       
   294 
   313 
   295 !JavaByteCodeProcessor methodsFor:'initialization'!
   314 !JavaByteCodeProcessor methodsFor:'initialization'!
   296 
   315 
   297 reset
   316 reset
   298     pc := method startPC.
   317     pc := method startPC.
   299     byteCode := method byteCode.
   318     byteCode := method byteCode.
   300     constantPool := method javaClass constantPool.
   319     constantPool := method javaClass constantPool.
   301 
   320 
   302     "Modified: / 17-03-2011 / 14:53:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
   321     "Modified: / 17-03-2011 / 14:53:03 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
   303 ! !
   322 ! !
   304 
       
   305 
   323 
   306 !JavaByteCodeProcessor methodsFor:'instructions'!
   324 !JavaByteCodeProcessor methodsFor:'instructions'!
   307 
   325 
   308 aaload
   326 aaload
   309     "raise an error: must be redefined in concrete subclass(es)"
   327     "raise an error: must be redefined in concrete subclass(es)"
  2279     ^ self subclassResponsibility
  2297     ^ self subclassResponsibility
  2280 
  2298 
  2281     "Created: / 17-03-2011 / 16:58:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
  2299     "Created: / 17-03-2011 / 16:58:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
  2282 ! !
  2300 ! !
  2283 
  2301 
  2284 
       
  2285 !JavaByteCodeProcessor methodsFor:'private-helpers'!
  2302 !JavaByteCodeProcessor methodsFor:'private-helpers'!
  2286 
  2303 
  2287 fetchByte
  2304 fetchByte
  2288     "fetch sign extended byte value stored in bytecode"
  2305     "fetch sign extended byte value stored in bytecode"
  2289     pc := pc + 1.
  2306     pc := pc + 1.
  2456 
  2473 
  2457 tos
  2474 tos
  2458     ^ context at:sp.
  2475     ^ context at:sp.
  2459 ! !
  2476 ! !
  2460 
  2477 
  2461 
       
  2462 !JavaByteCodeProcessor methodsFor:'private-logging'!
  2478 !JavaByteCodeProcessor methodsFor:'private-logging'!
  2463 
  2479 
  2464 log: aMessage
  2480 log: aMessage
  2465 self class log: aMessage.
  2481 self class log: aMessage.
  2466 
  2482 
  2467     "Created: / 17-03-2011 / 14:59:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
  2483     "Created: / 17-03-2011 / 14:59:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
  2468 ! !
  2484 ! !
  2469 
       
  2470 
  2485 
  2471 !JavaByteCodeProcessor methodsFor:'processing loop'!
  2486 !JavaByteCodeProcessor methodsFor:'processing loop'!
  2472 
  2487 
  2473 enterProcessingLoop
  2488 enterProcessingLoop
  2474     Context cannotReturnSignal handle: 
  2489     Context cannotReturnSignal handle: 
  2559 
  2574 
  2560     "Modified: / 17-03-2011 / 15:01:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
  2575     "Modified: / 17-03-2011 / 15:01:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
  2561     "Modified: / 22-03-2011 / 20:55:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2576     "Modified: / 22-03-2011 / 20:55:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  2562 ! !
  2577 ! !
  2563 
  2578 
  2564 
       
  2565 !JavaByteCodeProcessor class methodsFor:'documentation'!
  2579 !JavaByteCodeProcessor class methodsFor:'documentation'!
  2566 
  2580 
  2567 version
  2581 version
  2568     ^ '$Header: /cvs/stx/stx/libjava/JavaByteCodeProcessor.st,v 1.5 2013-02-25 11:15:31 vrany Exp $'
  2582     ^ '$Header: /cvs/stx/stx/libjava/JavaByteCodeProcessor.st,v 1.5 2013-02-25 11:15:31 vrany Exp $'
  2569 !
  2583 !