compiler/PPCUnknownNode.st
changeset 438 20598d7ce9fa
parent 422 116d2b2af905
child 452 9f4558b3be66
equal deleted inserted replaced
437:54b3bc9e3987 438:20598d7ce9fa
    50 
    50 
    51 prefix
    51 prefix
    52 	^ #parser
    52 	^ #parser
    53 ! !
    53 ! !
    54 
    54 
    55 !PPCUnknownNode methodsFor:'as yet unclassified'!
    55 !PPCUnknownNode methodsFor:'analysis'!
    56 
    56 
    57 firstCharSet
    57 firstCharSet
    58 	^ parser firstCharSet
    58 	^ parser firstCharSet
    59 ! !
    59 ! !
    60 
    60 
    67 
    67 
    68 hash
    68 hash
    69 	^ super hash bitXor: parser hash
    69 	^ super hash bitXor: parser hash
    70 ! !
    70 ! !
    71 
    71 
    72 !PPCUnknownNode methodsFor:'compiling'!
       
    73 
       
    74 compileWith: compiler effect: effect id: id
       
    75 	| compiledChild compiledParser |
       
    76 	compiler startMethod: id.
       
    77 	
       
    78 	compiledParser := parser copy.
       
    79 	"Compile all the children and call compiled version of them instead of the original one"
       
    80 	compiledParser children do: [ :child | 
       
    81 		compiledChild := child compileWith: compiler.
       
    82 		compiledParser replace: child with: compiledChild bridge.
       
    83 	].
       
    84 	
       
    85 	compiler addConstant: compiledParser as: id. 
       
    86 	
       
    87 	compiler addVariable: 'retval'.
       
    88 	compiler add: 'self clearError.'.
       
    89 	compiler add: '(retval := ', id, ' parseOn: context) isPetitFailure'.
       
    90 	compiler indent.
       
    91 	compiler add: ' ifTrue: [self error: retval message at: retval position ].'.
       
    92 	compiler dedent.
       
    93 	compiler add: 'error := retval isPetitFailure.'.
       
    94 	compiler add: '^ retval'.
       
    95  ^ compiler stopMethod.
       
    96 ! !
       
    97 
       
    98 !PPCUnknownNode methodsFor:'transformation'!
    72 !PPCUnknownNode methodsFor:'transformation'!
    99 
    73 
   100 replace: node with: anotherNode
    74 replace: node with: anotherNode
   101 	parser replace: node with: anotherNode
    75 	parser replace: node with: anotherNode
       
    76 ! !
       
    77 
       
    78 !PPCUnknownNode methodsFor:'visiting'!
       
    79 
       
    80 accept: visitor
       
    81 	^ visitor visitUnknownNode: self
   102 ! !
    82 ! !
   103 
    83 
   104 !PPCUnknownNode class methodsFor:'documentation'!
    84 !PPCUnknownNode class methodsFor:'documentation'!
   105 
    85 
   106 version_HG
    86 version_HG