eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'STCCompilerInterface':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: STCCompilerInterface


Inheritance:

   Object
   |
   +--STCCompilerInterface

Package:
stx:libcomp
Category:
System-Compiler
Version:
rev: 1.84 date: 2023/12/01 23:58:14
user: cg
file: STCCompilerInterface.st directory: libcomp
module: stx stc-classLibrary: libcomp

Description:


a refactored complex method - originally found in ByteCodeCompiler.

self new 
    parserFlags:ParserFlags new;
    ensureExternalToolsArePresent

copyright

COPYRIGHT (c) 1989 by Claus Gittinger COPYRIGHT (c) 2006 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

accessing
o  getCCDefine
return a string which was used to identify the C-Compiler used
when STX was compiled, and which should be passed down when compiling methods.
For example, when compiled with GNUC, this is '__GNUC__';
on windows, this is either '__VISUAL__', '__BORLANDC__' or '__MINGW64__'

Usage example(s):

     STCCompilerInterface getCCDefine

o  getCPUDefine
return a string which was used to identify this CPU type when STX was
compiled, and which should be passed down when compiling methods.
For example, on a 386 (and successors), this may be '-D__x86__';
on a vax, this would be '-D__vax__'.
This is normally not of interest to 'normal' users; however, it is passed
down to the c-compiler when methods are incrementally compiled to machine code.
Do not use this for CPU determination; only to pass on to stc for compilation.
(see OperatingSystem getCPUType for this)

Usage example(s):

     STCCompilerInterface getCPUDefine

o  getOSDefine
return a string which was used to identify this machine when stx was
compiled, and which should be passed down when compiling methods.
For example, on linux, this is '-D__linux__'; on osx, it is '-D__osx__'.
Do not use this for OS determination; only to pass on to stc for compilation.
(see OperatingSystem getOSType for this)

Usage example(s):

     STCCompilerInterface getOSDefine

o  stcPathOf: command
return the path to an stc command, or nil if not found.

Usage example(s):

     STCCompilerInterface stcPathOf:'stc'     

o  verbose
if on, trace command execution on the Transcript

o  verbose: aBoolean
if on, trace command execution on the Transcript


Instance protocol:

accessing
o  cFileName: aFilename
Modified (format): / 27-07-2023 / 16:01:32 / mobile

o  incrementalStcPath
return the path to the stc command for incremental method compilation,
or nil if not found.

o  originator: something

o  parserFlags: parserFlagsArg
Modified (format): / 27-07-2023 / 16:01:46 / mobile

o  stFileName: aFilename
Modified (format): / 27-07-2023 / 16:01:36 / mobile

error raising
o  parseError: messageText position: position
not normally reached

machine code generation
o  compileClassToMachineCode: aClass install: install generateCOnly: generateCOnly
this is called to compile a whole class using stc
(via the browser's special menu entry 'compile class with stc').
It saves the code to a tmporary, calls stc to create C-code, compiles it, links
it to a dll and loads it.
As you might expect, this takes some time and is therefore not done automatically;
used only for benchmarks and to track stc bugs.

o  compileToMachineCode: aString forClass: aClass selector: selector inCategory: categoryArg notifying: requestorArg install: install skipIfSame: skipIfSame silent: silent
this is called to compile primitive code.
It saves the code to a tmporary, calls stc to create C-code, compiles it, links
it to a tiny little dll and loads it.
As you already see, this takes some time and is therefore ONLY done for code containing prims;
all pure smalltalk code is compiled to bytecode and jitted by the VM.

Usage example(s):

     |m|

     Object subclass:#Test
            instanceVariableNames:''
            classVariableNames:''
            poolDictionaries:''
            category:'tests'.
     m := ByteCodeCompiler
            compileToMachineCode:'foo %{ RETURN (_MKSMALLINT(1)); %}'
            forClass:Test
            inCategory:'tests'
            notifying:nil
            install:false
            skipIfSame:false
            silent:false.
     m inspect

o  compileToMachineCode: aString forClass: aClass selector: selector inCategory: categoryArg notifying: requestorArg install: install skipIfSame: skipIfSame silent: silent generateCOnly: generateCOnly
this is called to compile methods with primitive code
(or via the browser's special menu entry 'compile with stc').
It saves the code to a tmporary, calls stc to create C-code, compiles it, links
it to a tiny little dll and loads it.
As you already see, this takes some time and is therefore ONLY done for code containing prims;
all pure smalltalk code is compiled to bytecode and jitted by the VM.

Usage example(s):

     |m|

     Object subclass:#Test
            instanceVariableNames:''
            classVariableNames:''
            poolDictionaries:''
            category:'tests'.
     m := ByteCodeCompiler
            compileToMachineCode:'foo %{ RETURN (_MKSMALLINT(1)); %}'
            forClass:Test
            inCategory:'tests'
            notifying:nil
            install:false
            skipIfSame:false
            silent:false.
     m inspect

machine code generation-helpers
o  compileToC_onError: aBlock
compile st to C using stc.
If any error happens, call aBlock passing it the fileName containing diagnostics

o  compileToExe_onError: aBlock
compile C to exe, using cc.
If any error happens, call aBlock passing it the fileName containing diagnostics

o  compileToObj_onError: aBlock
compile C to obj, using cc.
If any error happens, call aBlock passing it the fileName containing diagnostics

o  compileToS_onError: aBlock
compile C to assembler, using cc.
If any error happens, call aBlock passing it the fileName containing diagnostics

o  ensureExternalToolsArePresent
make it absolute, so that we are immune to directory changes

o  ensureModuleDirectoryExists
create a small README there ...

o  ensureSuperClassesAreLoadedOf: aClass

o  fileOutAllDefinitionsOf: aClass to: aStream rememberIn: definedClasses

o  generateSTSource: aString
generate a unique name, consisting of my processID and a sequence number

o  reportCompilationErrorFor: aCommand

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  reportCompilationErrorFor: aCommand fromFile: anErrorFilename
replace the filename string

o  setupCompilationCommandArguments
ParserFlags useBorlandC ifTrue:[

Usage example(s):

     self new 
        stFileName:'foo.st';
        setupCompilationCommandArguments; 
        inspect



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 17:05:37 GMT