STCCompilerInterface.st
changeset 2656 d3f4404f3e23
parent 2649 0e257259566f
child 2658 92f1a346dbeb
equal deleted inserted replaced
2655:646f8e5fd239 2656:d3f4404f3e23
   153     "this is called to compile primitive code.
   153     "this is called to compile primitive code.
   154      This is EXPERIMENTAL and going to be changed to raise an error,
   154      This is EXPERIMENTAL and going to be changed to raise an error,
   155      an redefined in subclasses which can do it (either by direct compilation, or by calling
   155      an redefined in subclasses which can do it (either by direct compilation, or by calling
   156      the external stc do do it)."
   156      the external stc do do it)."
   157 
   157 
   158     |handle oldMethod newMethod ok moduleFileName|
   158     |handle oldMethod newMethod ok moduleFileName dllFileName|
   159 
   159 
   160     install ifFalse:[
   160     install ifFalse:[
   161         "/ cannot do it uninstalled. reason:
   161         "/ cannot do it uninstalled. reason:
   162         "/ if it is loaded twice, the first version could be unloaded by
   162         "/ if it is loaded twice, the first version could be unloaded by
   163         "/ finalization, which would also unload the second version
   163         "/ finalization, which would also unload the second version
   213         "
   213         "
   214          if required, make a shared or otherwise loadable object file for it
   214          if required, make a shared or otherwise loadable object file for it
   215         "
   215         "
   216         originator activityNotification:'linking'.
   216         originator activityNotification:'linking'.
   217 
   217 
   218         oFileName := ObjectFileLoader createLoadableObjectFor:(oFileName asFilename withoutSuffix).
   218         dllFileName := ObjectFileLoader createLoadableObjectFor:(oFileName asFilename withoutSuffix name).
   219         oFileName isNil ifTrue:[
   219         dllFileName isNil ifTrue:[
   220             "/ something went wrong
   220             "/ something went wrong
   221             originator parseError:('link error: ' , ObjectFileLoader lastError) position:1.
   221             originator parseError:('link error: ' , ObjectFileLoader lastError) position:1.
   222             ^ #CannotLoad
   222             ^ #CannotLoad
   223         ].
   223         ].
   224         oFileName asFilename exists ifFalse:[
   224         dllFileName asFilename exists ifFalse:[
   225             originator parseError:'link failed - cannot create machine code' position:1.
   225             originator parseError:'link failed - cannot create machine code' position:1.
   226             ^ #CannotLoad
   226             ^ #CannotLoad
   227         ].
   227         ].
   228 
   228 
   229         oldMethod := classToCompileFor compiledMethodAt:selector.
   229         oldMethod := classToCompileFor compiledMethodAt:selector.
   232         "
   232         "
   233          load the method objectfile
   233          load the method objectfile
   234         "
   234         "
   235         originator activityNotification:'loading'.
   235         originator activityNotification:'loading'.
   236 
   236 
   237         handle := ObjectFileLoader loadMethodObjectFile:oFileName.
   237         handle := ObjectFileLoader loadMethodObjectFile:dllFileName.
   238         handle isNil ifTrue:[
   238         handle isNil ifTrue:[
   239             OperatingSystem removeFile:oFileName.
   239             OperatingSystem removeFile:dllFileName.
   240             "catch, so that #CannotLoad processing is done"
   240             "catch, so that #CannotLoad processing is done"
   241             Parser parseErrorSignal catch:[
   241             Parser parseErrorSignal catch:[
   242                 originator parseError:'dynamic load of machine code failed' position:1.
   242                 originator parseError:'dynamic load of machine code failed' position:1.
   243             ].
   243             ].
   244             ^ #CannotLoad
   244             ^ #CannotLoad
   316     ] ensure:[
   316     ] ensure:[
   317         parserFlags stcKeepSTIntermediate ifFalse:[
   317         parserFlags stcKeepSTIntermediate ifFalse:[
   318             OperatingSystem removeFile:stFileName.
   318             OperatingSystem removeFile:stFileName.
   319             OperatingSystem removeFile:'errorOutput'.
   319             OperatingSystem removeFile:'errorOutput'.
   320         ].
   320         ].
   321         parserFlags stcKeepOIntermediate == true ifFalse:[
   321         parserFlags stcKeepOIntermediate ~~ true ifTrue:[
   322             (oFileName notNil and:[oFileName asFilename exists]) ifTrue:[oFileName asFilename delete].
   322             (oFileName notNil and:[oFileName asFilename exists]) ifTrue:[oFileName asFilename delete].
   323         ].
   323         ].
   324         parserFlags stcKeepCIntermediate == true ifFalse:[
   324         parserFlags stcKeepCIntermediate ~~ true ifTrue:[
   325             (cFileName notNil and:[cFileName asFilename exists]) ifTrue:[cFileName asFilename delete].
   325             (cFileName notNil and:[cFileName asFilename exists]) ifTrue:[cFileName asFilename delete].
   326         ].
   326         ].
   327         OperatingSystem isMSDOSlike ifTrue:[
   327         OperatingSystem isMSDOSlike ifTrue:[
   328 "/            (mapFileName notNil and:[mapFileName asFilename exists]) ifTrue:[mapFileName asFilename delete].
   328 "/            (mapFileName notNil and:[mapFileName asFilename exists]) ifTrue:[mapFileName asFilename delete].
   329 "/            (libFileName notNil and:[libFileName asFilename exists]) ifTrue:[libFileName asFilename delete].
   329 "/            (libFileName notNil and:[libFileName asFilename exists]) ifTrue:[libFileName asFilename delete].
   459     ccPath includesSeparator ifTrue:[
   459     ccPath includesSeparator ifTrue:[
   460         command := '"',ccPath , '"' 
   460         command := '"',ccPath , '"' 
   461     ] ifFalse:[
   461     ] ifFalse:[
   462         command := ccPath
   462         command := ccPath
   463     ].
   463     ].
   464     command := command , ' ' , cFlags , ' -D__INCREMENTAL_COMPILE__ -c ' , cFileName, ' -o ', oFileName.
   464     "Note: Windows/bcc32 does not understand a space between -o and filename"
       
   465     command := command , ' ' , cFlags , ' -D__INCREMENTAL_COMPILE__ -o', oFileName, ' -c ' , cFileName.
   465 
   466 
   466     Verbose == true ifTrue:[
   467     Verbose == true ifTrue:[
   467         'executing: ' infoPrint. command infoPrintCR.
   468         'executing: ' infoPrint. command infoPrintCR.
   468     ].
   469     ].
   469     originator activityNotification:'compiling (' , ccPath , ')'.
   470     originator activityNotification:'compiling (' , ccPath , ')'.
   838 ! !
   839 ! !
   839 
   840 
   840 !STCCompilerInterface class methodsFor:'documentation'!
   841 !STCCompilerInterface class methodsFor:'documentation'!
   841 
   842 
   842 version
   843 version
   843     ^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.23 2011-08-09 10:51:54 stefan Exp $'
   844     ^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.24 2011-08-09 12:59:38 stefan Exp $'
   844 !
   845 !
   845 
   846 
   846 version_CVS
   847 version_CVS
   847     ^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.23 2011-08-09 10:51:54 stefan Exp $'
   848     ^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.24 2011-08-09 12:59:38 stefan Exp $'
   848 ! !
   849 ! !
   849 
   850 
   850 STCCompilerInterface initialize!
   851 STCCompilerInterface initialize!