compiler/PPCListNode.st
changeset 391 553a5456963b
child 392 9b297f0d949c
equal deleted inserted replaced
390:17ba167b8ee1 391:553a5456963b
       
     1 "{ Package: 'stx:goodies/petitparser/compiler' }"
       
     2 
       
     3 PPCNode subclass:#PPCListNode
       
     4 	instanceVariableNames:'children'
       
     5 	classVariableNames:''
       
     6 	poolDictionaries:''
       
     7 	category:'PetitCompiler-Nodes'
       
     8 !
       
     9 
       
    10 PPCListNode comment:''
       
    11 !
       
    12 
       
    13 !PPCListNode methodsFor:'accessing'!
       
    14 
       
    15 children
       
    16 	^ children
       
    17 !
       
    18 
       
    19 children: anObject
       
    20 	
       
    21 	children := anObject
       
    22 ! !
       
    23 
       
    24 !PPCListNode methodsFor:'analysis'!
       
    25 
       
    26 acceptsEpsilon
       
    27 	self subclassResponsibility
       
    28 !
       
    29 
       
    30 acceptsEpsilonOpenSet: set
       
    31 	self subclassResponsibility
       
    32 !
       
    33 
       
    34 replace: node with: anotherNode
       
    35 	children keysAndValuesDo: [ :index :child |
       
    36 		child == node ifTrue: [ children at: index put: anotherNode ] 
       
    37 	]
       
    38 ! !
       
    39 
       
    40 !PPCListNode methodsFor:'copying'!
       
    41 
       
    42 postCopy
       
    43 	super postCopy.
       
    44 	children := children copy
       
    45 ! !
       
    46 
       
    47 !PPCListNode methodsFor:'optimizing'!
       
    48 
       
    49 inline: changeStatus
       
    50 	| inlinedNode |
       
    51 	self children do: [ :child |
       
    52 		inlinedNode := child asInlined.
       
    53 		(inlinedNode ~= child) ifTrue: [ 
       
    54 			changeStatus change.
       
    55 			^ self replace: child with: inlinedNode.
       
    56 		]
       
    57 	]
       
    58 !
       
    59 
       
    60 optimize: params status: changeStatus
       
    61 	| retval |
       
    62 	retval := self.
       
    63 	retval := retval rewrite: params status: changeStatus.
       
    64 	retval := retval inline: params status: changeStatus.
       
    65 	
       
    66 	^ retval
       
    67 ! !
       
    68