compiler/PPCASTUtilities.st
changeset 544 69b6f2f0df1d
parent 518 a6d8b93441b0
equal deleted inserted replaced
543:02d90f0038fd 544:69b6f2f0df1d
     6 	instanceVariableNames:''
     6 	instanceVariableNames:''
     7 	classVariableNames:''
     7 	classVariableNames:''
     8 	poolDictionaries:''
     8 	poolDictionaries:''
     9 	category:'PetitCompiler-Support'
     9 	category:'PetitCompiler-Support'
    10 !
    10 !
       
    11 
    11 
    12 
    12 !PPCASTUtilities methodsFor:'checks'!
    13 !PPCASTUtilities methodsFor:'checks'!
    13 
    14 
    14 checkNodeIsFunctional: anRBBlockNode inClass: aClaas
    15 checkNodeIsFunctional: anRBBlockNode inClass: aClaas
    15     "Check whether the given node is purely functional or not. 
    16     "Check whether the given node is purely functional or not. 
    50             (allClassVarNames includes: node name) ifTrue:[
    51             (allClassVarNames includes: node name) ifTrue:[
    51                 PPCCompilationError new signal: 'code refers to a class variable named `',node name,'`'.
    52                 PPCCompilationError new signal: 'code refers to a class variable named `',node name,'`'.
    52                 ^ self.
    53                 ^ self.
    53             ].
    54             ].
    54             (Smalltalk includesKey: node name asSymbol) ifFalse:[ 
    55             (Smalltalk includesKey: node name asSymbol) ifFalse:[ 
    55                 PPCCompilationError new signalWith: 'code refers to an unknown variable named `',node name,'`'.
    56                 PPCCompilationError new signal: 'code refers to an unknown variable named `',node name,'`'.
    56                 ^ self.                    
    57                 ^ self.                    
    57             ].
    58             ].
    58         ]
    59         ]
    59     ].
    60     ].
    60     self withAllMessageNodesOf: anRBBlockNode sentToSelfDo:[:node |
    61     self withAllMessageNodesOf: anRBBlockNode sentToSelfDo:[:node |
    61         | method |
    62         | method |
    62         
    63         
    63         method := aClaas lookupSelector: node selector.
    64         method := aClaas lookupSelector: node selector.
    64         method isNil ifTrue:[
    65         method isNil ifTrue:[
    65             PPCCompilationError new signalWith: 'code contains self-send to non-existent method'.        
    66             PPCCompilationError new signal: 'code contains self-send to non-existent method'.        
    66             ^ self
    67             ^ self
    67         ].
    68         ].
    68         self checkNodeIsFunctional: method parseTree inClass: method methodClass.
    69         self checkNodeIsFunctional: method parseTree inClass: method methodClass.
    69     ].      
    70     ].      
    70     self withAllSuperNodesOf: anRBBlockNode do: [ :node | 
    71     self withAllSuperNodesOf: anRBBlockNode do: [ :node | 
    71         PPCCompilationError new signalWith: 'code contains a super-send'.
    72         PPCCompilationError new signal: 'code contains a super-send'.
    72         ^ self
    73         ^ self
    73     ].
    74     ].
    74 
    75 
    75     "Created: / 27-07-2015 / 12:15:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    76     "Created: / 27-07-2015 / 12:15:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    76     "Modified: / 17-08-2015 / 13:49:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    77     "Modified: / 08-09-2015 / 02:48:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    77 ! !
    78 ! !
    78 
    79 
    79 !PPCASTUtilities methodsFor:'enumerating'!
    80 !PPCASTUtilities methodsFor:'enumerating'!
    80 
    81 
    81 withAllMessageNodesOf: anRBProgramNode do: aBlock
    82 withAllMessageNodesOf: anRBProgramNode do: aBlock
   142 
   143 
   143     "Created: / 18-06-2015 / 22:02:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   144     "Created: / 18-06-2015 / 22:02:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   144     "Modified (comment): / 27-07-2015 / 11:27:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   145     "Modified (comment): / 27-07-2015 / 11:27:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   145 ! !
   146 ! !
   146 
   147 
       
   148 !PPCASTUtilities class methodsFor:'documentation'!
       
   149 
       
   150 version_HG
       
   151 
       
   152     ^ '$Changeset: <not expanded> $'
       
   153 ! !
       
   154