compiler/PPCNotNode.st
changeset 438 20598d7ce9fa
parent 422 116d2b2af905
child 452 9f4558b3be66
equal deleted inserted replaced
437:54b3bc9e3987 438:20598d7ce9fa
    23 
    23 
    24 isFirstSetTerminal
    24 isFirstSetTerminal
    25 	^ true
    25 	^ true
    26 ! !
    26 ! !
    27 
    27 
    28 !PPCNotNode methodsFor:'compiling'!
    28 !PPCNotNode methodsFor:'visiting'!
    29 
    29 
    30 compileWith: compiler effect: effect id: id
    30 accept: visitor
    31 
    31 	^ visitor visitNotNode: self
    32 	compiler startMethod: id.
       
    33 	compiler addVariable: 'memento'.
       
    34 	compiler add: (compiler smartRemember: child).
       
    35 	
       
    36 	compiler call: (child compileWith: compiler).
       
    37 	compiler add: (compiler smartRestore: child).
       
    38 
       
    39 	compiler add: '^ error ifFalse: [ self error ] ifTrue: [ self clearError. nil ]'.
       
    40  ^ compiler stopMethod.
       
    41 ! !
    32 ! !
    42 
    33 
    43 !PPCNotNode methodsFor:'optimizing'!
       
    44 
       
    45 optimize: params 
       
    46 	(self rewrite: params) ifTrue: [ 
       
    47 		^ true.
       
    48 	].
       
    49 	^ super optimize: params.
       
    50 !
       
    51 
       
    52 rewrite: changeStatus
       
    53 	(child isKindOf: PPCAbstractLiteralNode) ifTrue: [  
       
    54 		changeStatus change.
       
    55 		^ PPCNotLiteralNode new
       
    56 			name: self name;
       
    57 			literal: self child literal;
       
    58 			yourself
       
    59 	]. 
       
    60 
       
    61 	(child isKindOf: PPCMessagePredicateNode) ifTrue: [  
       
    62 		changeStatus change.
       
    63 		^ PPCNotMessagePredicateNode new
       
    64 			name: self name;
       
    65 			message: child message;
       
    66 			yourself
       
    67 	].
       
    68 
       
    69 	(child isKindOf: PPCCharSetPredicateNode) ifTrue: [  
       
    70 		changeStatus change.
       
    71 		^ PPCNotCharSetPredicateNode new
       
    72 			name: self name;
       
    73 			predicate: child predicate;
       
    74 			yourself
       
    75 	].
       
    76 
       
    77 	"Can do the fast version, because we throw away the result and return  nil"
       
    78 	(self allNodes anySatisfy: [ :node | node asFast ~= node ]) ifTrue: [  
       
    79 		changeStatus change.
       
    80 		self replace: child with: (child transform: [:node | node asFast]).
       
    81 	]
       
    82 ! !
       
    83