Merged in PetitCompiler-JanVrany.170, PetitCompiler-Tests-JanKurs.116, PetitCompiler-Extras-Tests-JanKurs.29, PetitCompiler-Benchmarks-JanKurs.19
Name: PetitCompiler-JanVrany.170
Author: JanVrany
Time: 24-08-2015, 03:19:51.340 PM
UUID: c20a744f-3b41-4aaa-bb8a-71ce74a2a952
Name: PetitCompiler-Tests-JanKurs.116
Author: JanKurs
Time: 24-08-2015, 11:37:54.332 AM
UUID: 549e0927-358a-4a1b-8270-050ccfcb4217
Name: PetitCompiler-Extras-Tests-JanKurs.29
Author: JanKurs
Time: 24-08-2015, 11:36:52.503 AM
UUID: ea1dbb67-f884-4237-8f34-adb0677c0954
Name: PetitCompiler-Benchmarks-JanKurs.19
Author: JanKurs
Time: 24-08-2015, 11:48:47.045 AM
UUID: 1c342fdb-8ddd-4104-9c47-a8f589c51694
"{ Package: 'stx:goodies/petitparser/compiler' }"
"{ NameSpace: Smalltalk }"
PPCNodeVisitor subclass:#PPCInliningVisitor
instanceVariableNames:'canInline acceptedNodes'
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Visitors'
!
!PPCInliningVisitor methodsFor:'initialization'!
initialize
super initialize.
acceptedNodes := 0
! !
!PPCInliningVisitor methodsFor:'testing'!
canInline
^ acceptedNodes > 1
! !
!PPCInliningVisitor methodsFor:'visiting'!
beforeAccept: node
acceptedNodes := acceptedNodes + 1.
super beforeAccept: node
!
markForInline: node
self canInline ifTrue: [
node markForInline.
].
^ node
!
visitActionNode: node
"Only mark unnamed sequence nodes for inlining.
Named nodes should not be inlined as they should make a method.
There's little point in inlining non-sequence nodes, so don't
enforce inlining on those. Some (JK :-) may prefer them non-inlined
(for debugging purposes)"
(node child isSequenceNode and:[node child name isNil]) ifTrue: [ node child markForInline ].
^ super visitActionNode: node.
"Created: / 13-05-2015 / 16:25:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 31-07-2015 / 08:20:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
visitCharSetPredicateNode: node
^ self markForInline: node
!
visitCharacterNode: node
^ self markForInline: node
!
visitLiteralNode: node
^ self markForInline: node
!
visitMessagePredicateNode: node
^ self markForInline: node
!
visitNilNode: node
^ self markForInline: node
!
visitNotCharSetPredicateNode: node
^ self markForInline: node
!
visitNotLiteralNode: node
^ self markForInline: node
!
visitNotMessagePredicateNode: node
^ self markForInline: node
!
visitPluggableNode: node
"Sadly, on Smalltalk/X blocks cannot be inlined because
the VM does not provide enough information to map
it back to source code. Very bad indeed!!"
((Smalltalk respondsTo:#isSmalltalkX) and:[ Smalltalk isSmalltalkX ]) ifFalse:[
self markForInline: node
].
^ super visitPluggableNode: node.
"Modified: / 23-04-2015 / 12:15:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
visitStarCharSetPredicateNode: node
^ self markForInline: node
!
visitStarMessagePredicateNode: node
^ self markForInline: node
!
visitTokenConsumeNode: node
"super visitTokenConsumeNode: node."
node name isNil ifTrue: [
self markForInline: node
].
^ node
!
visitTokenStarMessagePredicateNode: node
^ self markForInline: node
!
visitTokenStarSeparatorNode: node
^ self markForInline: node
!
visitTokenWhitespaceNode: node
super visitTokenWhitespaceNode: node.
self markForInline: node.
^ node
!
visitTokenizingParserNode: node
"skip tokens"
"skip whitespace"
"self visit: node whitespace."
self visit: node parser.
^ node
! !