compiler/PPCPluggableNode.st
changeset 438 20598d7ce9fa
parent 422 116d2b2af905
child 452 9f4558b3be66
equal deleted inserted replaced
437:54b3bc9e3987 438:20598d7ce9fa
    17 !
    17 !
    18 
    18 
    19 block: anObject
    19 block: anObject
    20 	
    20 	
    21 	block := anObject
    21 	block := anObject
       
    22 !
       
    23 
       
    24 prefix
       
    25 	^ #plug
    22 ! !
    26 ! !
    23 
    27 
    24 !PPCPluggableNode methodsFor:'as yet unclassified'!
    28 !PPCPluggableNode methodsFor:'analysis'!
    25 
    29 
    26 acceptsEpsilon
    30 acceptsEpsilon
    27 	^ true
    31 	^ true
    28 !
    32 !
    29 
    33 
    30 acceptsEpsilonOpenSet: set
    34 acceptsEpsilonOpenSet: set
    31 	^ true
    35 	^ true
    32 !
    36 !
    33 
    37 
    34 asInlined
       
    35     "Sadly, on Smalltalk/X blocks cannot be inlined because
       
    36      the VM does not provide enough information to map
       
    37      it back to source code. Very bad indeed!!"
       
    38 
       
    39     ((Smalltalk respondsTo:#isSmalltalkX) and:[ Smalltalk isSmalltalkX ]) ifTrue:[
       
    40 		^ super asInlined
       
    41     ] ifFalse:[
       
    42 		^ PPCInlinePluggableNode new
       
    43 			name: name;
       
    44 			block: block;
       
    45 			yourself
       
    46     ]
       
    47 
       
    48 !
       
    49 
       
    50 compileWith: compiler effect: effect id: id
       
    51 	| blockId |
       
    52 	blockId := compiler idFor: block prefixed: #block.
       
    53 	
       
    54 	compiler startMethod: id.
       
    55 	compiler addConstant: block as: blockId.
       
    56 	compiler add: '^ ', blockId, ' value: context.'.
       
    57  ^ compiler stopMethod.
       
    58 !
       
    59 
       
    60 firstCharSet
    38 firstCharSet
    61 	^ PPCharSetPredicate on: [:char | (block asParser parse: char asString) isPetitFailure not ]
    39 	^ PPCharSetPredicate on: [:char | (block asParser parse: char asString) isPetitFailure not ]
    62 !
       
    63 
       
    64 prefix
       
    65 	^ #plug
       
    66 ! !
    40 ! !
    67 
    41 
    68 !PPCPluggableNode methodsFor:'comparing'!
    42 !PPCPluggableNode methodsFor:'comparing'!
    69 
    43 
    70 = anotherNode
    44 = anotherNode
    74 
    48 
    75 hash
    49 hash
    76 	^ super hash bitXor: block hash
    50 	^ super hash bitXor: block hash
    77 ! !
    51 ! !
    78 
    52 
       
    53 !PPCPluggableNode methodsFor:'visiting'!
       
    54 
       
    55 accept: visitor
       
    56 	^ visitor visitPluggableNode: self
       
    57 ! !
       
    58