Fixed PPCCompiler: must refetch class afer updating instance variables of a given class.
The reason is, that in (at least) Smalltalk/X modyfing a layout of a class results
in creating a new class rather than updating an old one and migrating instances, i.e.,
the old class is not identical with the new class. Therefore, to install methods in in
correct class, we have to refetch new version from system dictionary. On Pharo it
should not harm
--- a/compiler/PPCCompiler.st Thu Oct 30 23:03:03 2014 +0000
+++ b/compiler/PPCCompiler.st Thu Oct 30 23:20:35 2014 +0000
@@ -313,12 +313,12 @@
self callOnLine: (compilerTree compileWith: self).
self stopMethod.
- self installMethodsAndVariables: compiledParser.
+ self installVariablesAndMethods.
compiledParser referringParser: parser.
^ compiledParser
- "Modified: / 26-10-2014 / 22:04:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 30-10-2014 / 23:10:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
copy: parser
@@ -331,13 +331,6 @@
]
!
-installMethodsAndVariables: class
-
- self installVariables: class.
- self installMethods: class.
-
-!
-
installVariables: class
| string |
string := class constants keys inject: '' into: [:r :e | r, ' ', e ].
@@ -346,6 +339,25 @@
"Modified: / 26-10-2014 / 22:01:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+installVariablesAndMethods
+ "Updates the class and compile generated code"
+
+ | compiledParserClassName |
+
+ compiledParserClassName := compiledParser name.
+ self installVariables: compiledParser.
+ "Now we have to refetch the class again. The reason is, that
+ in (at least) Smalltalk/X modyfing a layout of a class results
+ in creating a new class rather than updating an old one and migrating
+ instances. Therefore, to install methods in in correct class, we have
+ to refetch new version from system dictionary. On Pharo it should not harm."
+ compiledParser := Smalltalk at: compiledParserClassName.
+
+ self installMethods: compiledParser.
+
+ "Created: / 30-10-2014 / 23:15:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
optimize: parser params: params
| retval |
retval := parser optimizeTree: params.