Do not try to inline PPCPluggableNode on Smalltalk/X
Sadly, on Smalltalk/X blocks cannot be inlined because
the VM does not provide enough information to map it back
to the source code. Very bad indeed!
"{ Package: 'stx:goodies/petitparser/compiler' }"
PPCNode subclass:#PPCPluggableNode
instanceVariableNames:'block'
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Nodes'
!
!PPCPluggableNode methodsFor:'accessing'!
block
^ block
!
block: anObject
block := anObject
! !
!PPCPluggableNode methodsFor:'as yet unclassified'!
acceptsEpsilon
^ true
!
acceptsEpsilonOpenSet: set
^ true
!
asInlined
"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 ]) ifTrue:[
^ super asInlined
] ifFalse:[
^ PPCInlinePluggableNode new
name: name;
block: block;
yourself
]
"Modified: / 06-11-2014 / 01:46:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
compileWith: compiler effect: effect id: id
| blockId |
blockId := compiler idFor: block prefixed: #block.
compiler startMethod: id.
compiler addConstant: block as: blockId.
compiler add: '^ ', blockId, ' value: context.'.
^ compiler stopMethod.
!
firstCharParser
^ block asParser
!
firstCharSet
^ PPCharSetPredicate on: [:char | (block asParser parse: char asString) isPetitFailure not ]
!
prefix
^ #plug
! !