Portability - test if RPackageOrganizer is present...
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sun, 26 Oct 2014 22:05:59 +0000
changeset 394 ba6a64ffe00d
parent 393 00381102a9b5
child 395 c6c712fc15b7
Portability - test if RPackageOrganizer is present... ...if not, do not register new package using it. RPackage is Pharo specific thing not present in other Smalltalks.
compiler/PPCCompiler.st
--- a/compiler/PPCCompiler.st	Sun Oct 26 22:00:05 2014 +0000
+++ b/compiler/PPCCompiler.st	Sun Oct 26 22:05:59 2014 +0000
@@ -8,6 +8,7 @@
 	category:'PetitCompiler-Core'
 !
 
+
 !PPCCompiler class methodsFor:'instance creation'!
 
 new
@@ -272,37 +273,47 @@
 !
 
 compileTree: compilerTree as: name parser: parser params: params
-	|  |
-	params do: [ :p | 
-		(p key = #guards) ifTrue: [ self guards: p value ].
-	].	
+        | rPackageOrganizer |
+
+        params do: [ :p | 
+                (p key = #guards) ifTrue: [ self guards: p value ].
+        ].      
+
+        "
+                To create a new Package so that a new classes are not in PetitCompiler package.
+                TODO JK: This is HACK, needs some more interoperable approach
+        "
+        rPackageOrganizer := Smalltalk at: #RPackageOrganizer.
+        rPackageOrganizer notNil ifTrue:[
+            rPackageOrganizer default registerPackageNamed: 'PetitCompiler-Generated'.
+        ].
 
-	"
-		To create a new Package so that a new classes are not in PetitCompiler package.
-		TODO JK: This is HACK, needs some more interoperable approach
-	"
-	RPackageOrganizer default registerPackageNamed: 'PetitCompiler-Generated'.
-	compiledParser := (Smalltalk at: name ifAbsent: [ nil ]).
-	compiledParser ifNil: [ 
-							PPCompiledParser subclass: name.
-							compiledParser := Smalltalk at: name.
-							compiledParser category: 'PetitCompiler-Generated'							
-						] ifNotNil: [ 
-							self clean: compiledParser 
-						].	
-	compiledParser constants removeAll.
-	
+        compiledParser := (Smalltalk at: name ifAbsent: [ nil ]).
+        compiledParser ifNil: [ 
+                PPCompiledParser subclass: name
+                   instanceVariableNames:''
+                   classVariableNames:''
+                   poolDictionaries:''
+                   category:'PetitCompiler-Generated'.                
+                compiledParser := Smalltalk at: name.
+        ] ifNotNil: [ 
+                self clean: compiledParser 
+        ].      
+        compiledParser constants removeAll.
+        
 
-	
-	self startMethod: #start.
-	self add: '^ '.
-	self callOnLine: (compilerTree compileWith: self).
-	self stopMethod.
+        
+        self startMethod: #start.
+        self add: '^ '.
+        self callOnLine: (compilerTree compileWith: self).
+        self stopMethod.
 
-	self installMethodsAndVariables: compiledParser.
+        self installMethodsAndVariables: compiledParser.
 
-	compiledParser referringParser: parser.
-	^ compiledParser
+        compiledParser referringParser: parser.
+        ^ compiledParser
+
+    "Modified: / 26-10-2014 / 22:04:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 copy: parser
@@ -323,9 +334,11 @@
 !
 
 installVariables: class
-	| string |
-	string := class constants keys inject: '' into: [:r :e | r, ' ', e  ].
-	PPCompiledParser subclass: class name instanceVariableNames: string classVariableNames: '' category: 'PetitCompiler-Generated'.
+        | string |
+        string := class constants keys inject: '' into: [:r :e | r, ' ', e  ].
+        PPCompiledParser subclass: class name instanceVariableNames: string classVariableNames: '' poolDictionaries:'' category: 'PetitCompiler-Generated'.
+
+    "Modified: / 26-10-2014 / 22:01:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 optimize: parser params: params
@@ -419,3 +432,10 @@
 	^ lastMethod canInline
 ! !
 
+!PPCCompiler class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+