compiler/PPCClassBuilder.st
changeset 515 b5316ef15274
parent 502 1e45d3c96ec5
child 516 3b81c9e53352
--- a/compiler/PPCClassBuilder.st	Fri Jul 24 15:06:54 2015 +0100
+++ b/compiler/PPCClassBuilder.st	Mon Aug 17 12:13:16 2015 +0100
@@ -10,6 +10,14 @@
 	category:'PetitCompiler-Core'
 !
 
+!PPCClassBuilder class methodsFor:'instance creation'!
+
+new
+    "return an initialized instance"
+
+    ^ self basicNew initialize.
+! !
+
 !PPCClassBuilder methodsFor:'accessing'!
 
 compiledClass
@@ -66,6 +74,16 @@
 !
 
 cleanGeneratedMethods
+    (compiledClass methodDictionary size == 0) ifTrue: [ ^ self ].
+
+    "this is hack, but might help the performance..."
+    (compiledClass methods allSatisfy: [:m | m category beginsWith: 'generated']) ifTrue: [
+        compiledClass removeFromSystem.
+        compiledClass := nil.
+        ^ self
+    ].
+
+
     ((Smalltalk respondsTo:#isSmalltalkX) and:[ Smalltalk isSmalltalkX ]) ifTrue:[
         compiledClass methodsDo: [ :mthd |
             (mthd category beginsWith: 'generated') ifTrue:[
@@ -73,10 +91,17 @@
             ]
         ]
     ] ifFalse: [ 
+"		compiledClass methodsDo: [ :mthd |
+            (mthd category beginsWith: 'generated') ifTrue:[
+                compiledClass removeSelector: mthd selector.
+            ]
+        ]
+"
+"		Too slow, but more stable :("
         (compiledClass allProtocolsUpTo: compiledClass) do: [ :protocol |
             (protocol beginsWith: 'generated') ifTrue: [ 
                 compiledClass removeProtocol: protocol.
-            ]
+            ]		
         ]
     ]
 ! !
@@ -96,7 +121,7 @@
 installMethods
     methodDictionary values do: [ :method |
         (compiledClass methodDictionary includesKey: method methodName) ifFalse: [ 
-            compiledClass compileSilently: method code classified: method category.
+            compiledClass compileSilently: method source classified: method category.
         ]
     ]
 !