compiler/PPCPass.st
changeset 532 132d7898a2a1
child 534 a949c4fe44df
equal deleted inserted replaced
531:dc3d13c2837d 532:132d7898a2a1
       
     1 "{ Package: 'stx:goodies/petitparser/compiler' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
       
     4 
       
     5 PPCNodeVisitor subclass:#PPCPass
       
     6 	instanceVariableNames:'context'
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'PetitCompiler-Visitors'
       
    10 !
       
    11 
       
    12 !PPCPass class methodsFor:'running'!
       
    13 
       
    14 run: ir in: context
       
    15     "Run the pass on passed IR in given compilation context.
       
    16      Return (possibly transformed or completely new) IR."
       
    17 
       
    18     ^ self new run: ir in: context
       
    19 
       
    20     "Created: / 26-08-2015 / 22:31:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    21 ! !
       
    22 
       
    23 !PPCPass methodsFor:'accessing'!
       
    24 
       
    25 context: aPPCCompilationContext
       
    26     context := aPPCCompilationContext.
       
    27 
       
    28     "Created: / 26-08-2015 / 22:05:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    29 ! !
       
    30 
       
    31 !PPCPass methodsFor:'running'!
       
    32 
       
    33 run: ir
       
    34     "Actually run the pass on given IR (tree of PPCNode) and return
       
    35      (possibly transformed or completely new) another IR."
       
    36 
       
    37     context isNil ifTrue:[ 
       
    38         PPCCompilationError new signal: 'oops, no context set, use #context: before running a pass!!'.
       
    39     ].
       
    40     ^ self visit: ir.
       
    41 
       
    42     "Created: / 26-08-2015 / 22:30:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    43 !
       
    44 
       
    45 run: ir in: ctx
       
    46     "Actually run the pass on given IR (tree of PPCNode) in given
       
    47      compilation context and return (possibly transformed or completely 
       
    48      new) another IR."
       
    49 
       
    50     context := ctx.
       
    51     ^ self run: ir.
       
    52 
       
    53     "Created: / 26-08-2015 / 22:33:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    54 ! !
       
    55