Added static analysis of blocks when inlining. Allow inlining only when block is functional
...i.e., does not access any shared state (in instance or class variables). If the block does
a self-send, the sent method has to be (transitively) functional too.
To allow for self-sends in action blocks, copy (transitively) self-sent methods to target
parser. This is safe as these self-sent methods are guarnateed to be functional.
"{ Package: 'stx:goodies/petitparser/compiler/tests' }"
"{ NameSpace: Smalltalk }"
TestCase subclass:#PPCOptimizeChoicesTest
instanceVariableNames:'node result visitor configuration'
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Tests-Visitors'
!
!PPCOptimizeChoicesTest methodsFor:'as yet unclassified'!
asPPCTree: parser
^ parser compileWithConfiguration: configuration
!
setUp
| arguments |
super setUp.
visitor := PPCOptimizeChoices new.
arguments := PPCArguments default
profile: true.
configuration := PPCPluggableConfiguration on: [ :_self |
_self toPPCIr.
_self cacheFirstFollow.
].
configuration arguments: arguments.
!
testHasCommonPrefix
| foo bar |
foo := 'foo' asParser name: 'foo'; yourself.
bar := 'bar' asParser.
node := self asPPCTree: (foo, bar) / foo.
self assert: (visitor hasCommonPrefix: node children).
! !