Squeak Class Documentation category index | class index  
 
Decompiler
  category: System-Compiler
  superclass: InstructionStream
  subclasses:

I decompile a method in three phases:
Reverser: postfix byte codes -> prefix symbolic codes (nodes and atoms)
Parser: prefix symbolic codes -> node tree (same as the compiler)
Printer: node tree -> text (done by the nodes)

instance methods
  control
  blockForCaseTo:
blockTo:
checkForBlock:
statementsForCaseTo:
statementsTo:

  initialize-release
  initSymbols:
withTempNames:

  instruction decoding
  blockReturnTop
case:
doDup
doPop
doStore:
jump:
jump:if:
methodReturnConstant:
methodReturnReceiver
methodReturnTop
popIntoLiteralVariable:
popIntoReceiverVariable:
popIntoTemporaryVariable:
pushActiveContext
pushConstant:
pushLiteralVariable:
pushReceiver
pushReceiverVariable:
pushTemporaryVariable:
send:super:numArgs:
storeIntoLiteralVariable:
storeIntoReceiverVariable:
storeIntoTemporaryVariable:

  private
  convertToDoLoop
decompile:in:method:using:
interpretNextInstructionFor:
methodRefersOnlyOnceToTemp:
popTo:
quickMethod

  public access
  decompile:in:
decompile:in:method:
tempAt:

class methods
  class initialization
  initialize

instance methods
  control top  
 

blockForCaseTo:

Decompile a range of code as in statementsForCaseTo:, but return a block node.


 

blockTo:

Decompile a range of code as in statementsTo:, but return a block node.


 

checkForBlock:

We just saw a blockCopy: message. Check for a following block.


 

statementsForCaseTo:

Decompile the method from pc up to end and return an array of
expressions. If at run time this block will leave a value on the stack,
set hasValue to true. If the block ends with a jump or return, set exit
to the destination of the jump, or the end of the method; otherwise, set
exit = end. Leave pc = end.
Note that stack initially contains a CaseFlag which will be removed by
a subsequent Pop instruction, so adjust the StackPos accordingly.


 

statementsTo:

Decompile the method from pc up to end and return an array of
expressions. If at run time this block will leave a value on the stack,
set hasValue to true. If the block ends with a jump or return, set exit
to the destination of the jump, or the end of the method; otherwise, set
exit = end. Leave pc = end.


  initialize-release top  
 

initSymbols:


 

withTempNames:


  instruction decoding top  
 

blockReturnTop

No action needed


 

case:

statements = keyStmts CascadeFlag keyValueBlock ... keyStmts


 

doDup


 

doPop


 

doStore:

Only called internally, not from InstructionStream. StackOrBlock is stack
for store, statements for storePop.


 

jump:


 

jump:if:


 

methodReturnConstant:


 

methodReturnReceiver


 

methodReturnTop


 

popIntoLiteralVariable:


 

popIntoReceiverVariable:


 

popIntoTemporaryVariable:


 

pushActiveContext


 

pushConstant:


 

pushLiteralVariable:


 

pushReceiver


 

pushReceiverVariable:


 

pushTemporaryVariable:


 

send:super:numArgs:


 

storeIntoLiteralVariable:


 

storeIntoReceiverVariable:


 

storeIntoTemporaryVariable:


  private top  
 

convertToDoLoop

If statements contains the pattern
var _ startExpr.
[var <= limit] whileTrue: [...statements... var _ var + incConst]
then replace this by
startExpr to: limit by: incConst do: [:var | ...statements...]


 

decompile:in:method:using:


 

interpretNextInstructionFor:

Change false here will trace all state in Transcript.


 

methodRefersOnlyOnceToTemp:


 

popTo:


 

quickMethod


  public access top  
 

decompile:in:

See Decompiler|decompile:in:method:. The method is found by looking up
the message, aSelector, in the method dictionary of the class, aClass.


 

decompile:in:method:

Answer a MethodNode that is the root of the parse tree for the
argument, aMethod, which is the CompiledMethod associated with the
message, aSelector. Variables are determined with respect to the
argument, aClass.


 

tempAt:

Needed by BraceConstructor<PopIntoTemporaryVariable


class methods
  class initialization top  
 

initialize

Initialize an array of special constants returned by single-bytecode returns.