BCompiler.st
changeset 301 5c0add6f00e2
parent 298 118648c3b590
child 323 0d6e05191a9b
--- a/BCompiler.st	Fri Jul 12 16:52:21 1996 +0200
+++ b/BCompiler.st	Fri Jul 12 16:53:40 1996 +0200
@@ -15,7 +15,7 @@
 		maxStackDepth relocList'
 	classVariableNames:'JumpToAbsJump SequenceNumber STCCompilationDefines
 		STCCompilationIncludes STCCompilationOptions STCCompilation
-		ShareCode STCKeepCIntermediate'
+		ShareCode STCKeepCIntermediate STCModulePath'
 	poolDictionaries:''
 	category:'System-Compiler'
 !
@@ -92,8 +92,9 @@
 initialize
     ShareCode := true.
     STCKeepCIntermediate := false.
+    STCModulePath := './modules'.
 
-    "Modified: 9.7.1996 / 14:52:34 / cg"
+    "Modified: 12.7.1996 / 12:14:53 / cg"
 ! !
 
 !ByteCodeCompiler  class methodsFor:'compiling methods'!
@@ -633,6 +634,22 @@
     "
 !
 
+stcModulePath
+    "return the path, where temporary modules are created"
+
+    ^ STCModulePath
+
+    "Created: 12.7.1996 / 12:15:26 / cg"
+!
+
+stcModulePath:aPath
+    "set the path to the directory, where temporary modules are created"
+
+    STCModulePath := aPath
+
+    "Created: 12.7.1996 / 12:15:49 / cg"
+!
+
 stcPath 
     "return the path to the stc command, or nil if not found."
 
@@ -1909,7 +1926,17 @@
 
     |stFileName stream handle address flags command oFileName 
      initName newMethod ok status className sep class stcPath 
-     errorStream errorMessages eMsg m supers|
+     errorStream errorMessages eMsg m supers mP moduleFileName|
+
+    (mP := STCModulePath asFilename) exists ifFalse:[
+       mP makeDirectory
+    ].
+    (mP isDirectory 
+    and:[mP isReadable
+    and:[mP isWritable]]) ifFalse:[
+        self parseError:('no access to tempDir: ' , mP pathName) position:1.
+        ^ #CannotLoad
+    ].
 
     ObjectFileLoader isNil ifTrue:[^ #CannotLoad].
     STCCompilation == #never ifTrue:[^ #CannotLoad].
@@ -1929,7 +1956,7 @@
 
     initName := 'm_' , OperatingSystem getProcessId printString, '_' , SequenceNumber printString.
 
-    stFileName := initName , '.st'. 
+    stFileName := './' , initName , '.st'. 
     stream := stFileName asFilename writeStream.
     stream isNil ifTrue:[
         self parseError:'cannot create temporary sourcefile for compilation'.
@@ -2017,7 +2044,7 @@
     ].
 
     ok ifFalse:[
-        status couldNotExecute ifTrue:[
+        (status notNil and:[status couldNotExecute]) ifTrue:[
             eMsg := 'oops, no STC - cannot create machine code'
         ] ifFalse:[
             errorStream := 'errorOutput' asFilename readStream.
@@ -2046,15 +2073,18 @@
         'errorOutput' asFilename remove.
         self parseError:eMsg position:1.
         OperatingSystem removeFile:stFileName.
+        OperatingSystem removeFile:oFileName.
+        OperatingSystem removeFile:'errorOutput'.
         ^ #Error
     ].
 
-    'errorOutput' asFilename remove.
+    OperatingSystem removeFile:'errorOutput'.
 
     (ObjectFileLoader notNil 
     and:[ObjectFileLoader canLoadObjectFiles]) ifFalse:[
         self parseError:'no dynamic load configured - cannot load machine code' position:1.
         OperatingSystem removeFile:stFileName.
+        OperatingSystem removeFile:oFileName.
         ^ #CannotLoad
     ].
 
@@ -2065,13 +2095,20 @@
     oFileName := ObjectFileLoader createLoadableObjectFor:initName.
 
     "
+     move it into the modules directory
+    "
+    moduleFileName := STCModulePath , '/' , initName , '.' , (oFileName asFilename suffix).
+    oFileName asFilename moveTo:moduleFileName.
+    oFileName := moduleFileName.
+
+    "
      load the objectfile
     "
     self activityNotification:'loading'.
-    handle := ObjectFileLoader loadDynamicObject:oFileName.
+    handle := ObjectFileLoader loadDynamicObject:moduleFileName.
     handle isNil ifTrue:[
         OperatingSystem removeFile:stFileName.
-        OperatingSystem removeFile:oFileName.
+        OperatingSystem removeFile:moduleFileName.
         self parseError:'dynamic load failed - cannot create machine code' position:1.
         ^ #CannotLoad
     ].
@@ -2091,7 +2128,7 @@
             ObjectFileLoader unloadDynamicObject:handle.
 
             OperatingSystem removeFile:stFileName.
-            OperatingSystem removeFile:oFileName.
+            OperatingSystem removeFile:moduleFileName.
             self parseError:(eMsg , ' - cannot create machine code') position:1.
             ^ #CannotLoad
         ]
@@ -2147,7 +2184,7 @@
     ].
 
     OperatingSystem removeFile:stFileName.
-    OperatingSystem removeFile:oFileName.
+    OperatingSystem removeFile:moduleFileName.
     self parseError:'dynamic load failed' position:1.
     ^ #CannotLoad
 
@@ -2189,7 +2226,7 @@
 
     "Modified: 14.9.1995 / 22:33:04 / claus"
     "Modified: 28.12.1995 / 15:52:48 / stefan"
-    "Modified: 12.7.1996 / 11:16:18 / cg"
+    "Modified: 12.7.1996 / 12:37:45 / cg"
 !
 
 createLoadableObjectFor:baseFileName
@@ -2263,6 +2300,6 @@
 !ByteCodeCompiler  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.85 1996-07-12 10:11:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.86 1996-07-12 14:53:40 cg Exp $'
 ! !
 ByteCodeCompiler initialize!