compiler/PPCDelegateNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 03 Nov 2014 12:46:42 +0000
changeset 410 779556be95f8
parent 392 9b297f0d949c
child 422 116d2b2af905
permissions -rw-r--r--
Portability fixes in PPPredicateTest>>charactersDo: / parsedCharacterSet: * It is my understanding that charactersDo: should iterate over all signle byte characters. If so, the method suffer from off-by-one error, it should generate characters with code points 0..255. 256 is actually a two-byte character. Method changed accordingly. * Use Character>>asString instead of `String>>with:` which is safer w.r.t. multi-byte characters. Under Smalltalk/X, String may contain only signle byte characters.

"{ Package: 'stx:goodies/petitparser/compiler' }"

PPCNode subclass:#PPCDelegateNode
	instanceVariableNames:'child'
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Nodes'
!


!PPCDelegateNode methodsFor:'accessing'!

child
	^ child
!

child: whatever
	child := whatever 
!

children
	^ { child }
! !

!PPCDelegateNode methodsFor:'analysis'!

acceptsEpsilon
	^ child acceptsEpsilonOpenSet: (IdentitySet with: self).
!

acceptsEpsilonOpenSet: set
	(set includes: child) ifFalse: [ 
		set add: child.
		^ child acceptsEpsilonOpenSet: set 
	].
	^ false
! !

!PPCDelegateNode methodsFor:'optimizing'!

inline: changeStatus	
	| inlinedNode |
	inlinedNode := child asInlined.
	(inlinedNode ~= child) ifTrue: [ 
		changeStatus change.
		self replace: child with: inlinedNode.
	]
!

optimize: params status: changeStatus
	| retval |
	retval := self.
	
	retval := retval rewrite: params status: changeStatus.
	retval := retval inline: params status: changeStatus.
	
	^ retval
! !

!PPCDelegateNode methodsFor:'transformation'!

replace: node with: anotherNode
	child == node ifTrue: [ child := anotherNode ]
! !

!PPCDelegateNode class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !