compiler/PPCClassBuilder.st
changeset 515 b5316ef15274
parent 502 1e45d3c96ec5
child 516 3b81c9e53352
equal deleted inserted replaced
502:1e45d3c96ec5 515:b5316ef15274
     7 		methodDictionary compiledSuperclass'
     7 		methodDictionary compiledSuperclass'
     8 	classVariableNames:''
     8 	classVariableNames:''
     9 	poolDictionaries:''
     9 	poolDictionaries:''
    10 	category:'PetitCompiler-Core'
    10 	category:'PetitCompiler-Core'
    11 !
    11 !
       
    12 
       
    13 !PPCClassBuilder class methodsFor:'instance creation'!
       
    14 
       
    15 new
       
    16     "return an initialized instance"
       
    17 
       
    18     ^ self basicNew initialize.
       
    19 ! !
    12 
    20 
    13 !PPCClassBuilder methodsFor:'accessing'!
    21 !PPCClassBuilder methodsFor:'accessing'!
    14 
    22 
    15 compiledClass
    23 compiledClass
    16     ^ compiledClass
    24     ^ compiledClass
    64         self cleanGeneratedMethods.
    72         self cleanGeneratedMethods.
    65     ]
    73     ]
    66 !
    74 !
    67 
    75 
    68 cleanGeneratedMethods
    76 cleanGeneratedMethods
       
    77     (compiledClass methodDictionary size == 0) ifTrue: [ ^ self ].
       
    78 
       
    79     "this is hack, but might help the performance..."
       
    80     (compiledClass methods allSatisfy: [:m | m category beginsWith: 'generated']) ifTrue: [
       
    81         compiledClass removeFromSystem.
       
    82         compiledClass := nil.
       
    83         ^ self
       
    84     ].
       
    85 
       
    86 
    69     ((Smalltalk respondsTo:#isSmalltalkX) and:[ Smalltalk isSmalltalkX ]) ifTrue:[
    87     ((Smalltalk respondsTo:#isSmalltalkX) and:[ Smalltalk isSmalltalkX ]) ifTrue:[
    70         compiledClass methodsDo: [ :mthd |
    88         compiledClass methodsDo: [ :mthd |
    71             (mthd category beginsWith: 'generated') ifTrue:[
    89             (mthd category beginsWith: 'generated') ifTrue:[
    72                 compiledClass removeSelector: mthd selector.
    90                 compiledClass removeSelector: mthd selector.
    73             ]
    91             ]
    74         ]
    92         ]
    75     ] ifFalse: [ 
    93     ] ifFalse: [ 
       
    94 "		compiledClass methodsDo: [ :mthd |
       
    95             (mthd category beginsWith: 'generated') ifTrue:[
       
    96                 compiledClass removeSelector: mthd selector.
       
    97             ]
       
    98         ]
       
    99 "
       
   100 "		Too slow, but more stable :("
    76         (compiledClass allProtocolsUpTo: compiledClass) do: [ :protocol |
   101         (compiledClass allProtocolsUpTo: compiledClass) do: [ :protocol |
    77             (protocol beginsWith: 'generated') ifTrue: [ 
   102             (protocol beginsWith: 'generated') ifTrue: [ 
    78                 compiledClass removeProtocol: protocol.
   103                 compiledClass removeProtocol: protocol.
    79             ]
   104             ]		
    80         ]
   105         ]
    81     ]
   106     ]
    82 ! !
   107 ! !
    83 
   108 
    84 !PPCClassBuilder methodsFor:'compiling'!
   109 !PPCClassBuilder methodsFor:'compiling'!
    94 !
   119 !
    95 
   120 
    96 installMethods
   121 installMethods
    97     methodDictionary values do: [ :method |
   122     methodDictionary values do: [ :method |
    98         (compiledClass methodDictionary includesKey: method methodName) ifFalse: [ 
   123         (compiledClass methodDictionary includesKey: method methodName) ifFalse: [ 
    99             compiledClass compileSilently: method code classified: method category.
   124             compiledClass compileSilently: method source classified: method category.
   100         ]
   125         ]
   101     ]
   126     ]
   102 !
   127 !
   103 
   128 
   104 installVariables
   129 installVariables