compiler/PPCDelegateNode.st
changeset 391 553a5456963b
child 392 9b297f0d949c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/compiler/PPCDelegateNode.st	Sun Oct 26 01:03:31 2014 +0000
@@ -0,0 +1,75 @@
+"{ Package: 'stx:goodies/petitparser/compiler' }"
+
+PPCNode subclass:#PPCDelegateNode
+	instanceVariableNames:'child'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'PetitCompiler-Nodes'
+!
+
+PPCDelegateNode comment:''
+!
+
+
+!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> $'
+! !
+