compiler/PPCAbstractPredicateNode.st
changeset 391 553a5456963b
child 392 9b297f0d949c
equal deleted inserted replaced
390:17ba167b8ee1 391:553a5456963b
       
     1 "{ Package: 'stx:goodies/petitparser/compiler' }"
       
     2 
       
     3 PPCNode subclass:#PPCAbstractPredicateNode
       
     4 	instanceVariableNames:'predicate methodStrategy'
       
     5 	classVariableNames:''
       
     6 	poolDictionaries:''
       
     7 	category:'PetitCompiler-Nodes'
       
     8 !
       
     9 
       
    10 PPCAbstractPredicateNode comment:''
       
    11 !
       
    12 
       
    13 !PPCAbstractPredicateNode methodsFor:'accessing'!
       
    14 
       
    15 methodStrategy
       
    16 	
       
    17 	^ methodStrategy
       
    18 !
       
    19 
       
    20 methodStrategy: anObject
       
    21 	
       
    22 	methodStrategy := anObject
       
    23 !
       
    24 
       
    25 predicate
       
    26 	
       
    27 	^ predicate
       
    28 !
       
    29 
       
    30 predicate: anObject
       
    31 	
       
    32 	predicate := anObject
       
    33 !
       
    34 
       
    35 prefix
       
    36 	^ #predicate
       
    37 ! !
       
    38 
       
    39 !PPCAbstractPredicateNode methodsFor:'analysis'!
       
    40 
       
    41 = anotherNode
       
    42 	(self == anotherNode) ifTrue: [ ^ true ].
       
    43 	(anotherNode class = self class) ifFalse: [ ^ false ].
       
    44 	
       
    45 	(anotherNode name = name) ifFalse: [ ^ false ].
       
    46 	(anotherNode methodStrategy = methodStrategy) ifFalse: [ ^ false ].
       
    47 	^ anotherNode children = self children.
       
    48 !
       
    49 
       
    50 acceptsEpsilon
       
    51 	^ false
       
    52 !
       
    53 
       
    54 firstCharParser
       
    55 	^ PPPredicateObjectParser on: predicate message: 'predicate expected'.
       
    56 ! !
       
    57 
       
    58 !PPCAbstractPredicateNode methodsFor:'compiling'!
       
    59 
       
    60 bodyOfPredicate: compiler
       
    61 	self subclassResponsibility
       
    62 !
       
    63 
       
    64 compileWith: compiler effect: effect id: id
       
    65 	compiler startMethod: id.
       
    66 	compiler add: '^'.
       
    67 	self bodyOfPredicate: compiler.
       
    68  ^ compiler stopMethod.
       
    69 !
       
    70 
       
    71 extendClassification: classification
       
    72 	^ (classification asOrderedCollection addLast: false; yourself) asArray
       
    73 ! !
       
    74 
       
    75 !PPCAbstractPredicateNode methodsFor:'initialization'!
       
    76 
       
    77 initialize
       
    78 	super initialize.
       
    79 	methodStrategy := PPCMethodStrategy new
       
    80 ! !
       
    81 
       
    82 !PPCAbstractPredicateNode methodsFor:'optimizing'!
       
    83 
       
    84 asInlined
       
    85 	^ super asInlined
       
    86 "	(methodStrategy == (PPCInlineStrategy instance)) ifFalse: [ 
       
    87 		^ self copy 
       
    88 			methodStrategy: PPCInlineStrategy instance;
       
    89 			yourself
       
    90 	].
       
    91 	^ self"
       
    92 !
       
    93 
       
    94 optimize: params status: changeStatus
       
    95 	| retval |
       
    96 	retval := self.
       
    97 	retval := retval rewrite: params status: changeStatus.
       
    98 	retval := retval inline: params status: changeStatus.
       
    99 	
       
   100 	^ retval
       
   101 ! !
       
   102