STCCompilerInterface.st
author Claus Gittinger <cg@exept.de>
Fri, 17 May 2013 16:16:22 +0200
changeset 3170 fccd602cb081
parent 3159 697fcd52060b
child 3173 5b547821eb61
permissions -rw-r--r--
class: STCCompilerInterface comment/format in: #setupCompilationCommandArguments changed: #compileToC #compileToObj
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
 COPYRIGHT (c) 2006 by eXept Software AG
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
              All Rights Reserved
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 This software is furnished under a license and may be used
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 only in accordance with the terms of that license and with the
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 inclusion of the above copyright notice.   This software may not
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 be provided or otherwise made available to, or used by, any
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 other person.  No title to or ownership of the software is
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 hereby transferred.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"{ Package: 'stx:libcomp' }"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
Object subclass:#STCCompilerInterface
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
    16
	instanceVariableNames:'originator parserFlags initName theNonMetaclassToCompileFor
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
    17
		classToCompileFor stFileName cFileName oFileName stcFlags cFlags
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
    18
		stcPath ccPath requestor methodCategory executionStatus package'
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	classVariableNames:'SequenceNumber Verbose'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	poolDictionaries:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	category:'System-Compiler'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
!STCCompilerInterface class methodsFor:'documentation'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
copyright
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 COPYRIGHT (c) 1989 by Claus Gittinger
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 COPYRIGHT (c) 2006 by eXept Software AG
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
              All Rights Reserved
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 hereby transferred.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
documentation
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    a refactored complex method - originally found in ByteCodeCompiler.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
!STCCompilerInterface class methodsFor:'accessing'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
stcPathOf:command 
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    "return the path to an stc command, or nil if not found."
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    |f d reqdSuffix cmd|
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    "/ care for executable suffix
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    cmd := command.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    OperatingSystem isMSDOSlike ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
        reqdSuffix := 'exe'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    ] ifFalse:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
        OperatingSystem isVMSlike ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
            reqdSuffix := 'EXE'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    reqdSuffix notNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
        (f := cmd asFilename) suffix isEmpty ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
            cmd := (f withSuffix:reqdSuffix) name
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
        ]
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    "/ for our convenience, also check in current
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    "/ and parent directories; even if PATH does not
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    "/ include them ...
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    "/ look in current ...
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    d := Filename currentDirectory.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    (f := d construct:cmd) isExecutable ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
        ^ f pathName
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    "/ look in ../stc ...
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    d := d construct:'..'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    (f := (d construct:'stc') construct:cmd) isExecutable ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
        ^ f pathName
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    "/ look in ../../stc ...
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    d := d construct:'..'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    (f := (d construct:'stc') construct:cmd) isExecutable ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
        ^ f pathName
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    "/ ok, stc must be installed in some directory along the PATH
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    "/
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    ^ OperatingSystem pathOfCommand:command
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
     STCCompilerInterface stcPathOf:'stc'     
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    "Created: 13.9.1995 / 14:37:16 / claus"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
!STCCompilerInterface class methodsFor:'class initialization'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
initialize
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    Verbose := false.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
!STCCompilerInterface methodsFor:'accessing'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   111
cFileName:something
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   112
    cFileName := something.
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   113
!
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   114
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
incrementalStcPath 
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    "return the path to the stc command for incremental method compilation, 
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
     or nil if not found."
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    |f cmd|
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    (cmd := parserFlags stcPath) isEmptyOrNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
        (f := self class stcPathOf:'stc') notNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
            cmd := f
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
        ] ifFalse:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
            cmd := self class stcPathOf:'demostc'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
        ]
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    (cmd notNil and:[cmd includes:Character space]) ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
        cmd := '"' , cmd , '"'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    ^ cmd
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    "Created: 13.9.1995 / 14:36:36 / claus"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    "Modified: 13.9.1995 / 15:15:04 / claus"
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
originator:something
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    originator := something.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
parserFlags:something
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    parserFlags := something.
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   143
!
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   144
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   145
stFileName:something
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   146
    stFileName := something.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
!STCCompilerInterface methodsFor:'machine code generation'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   151
compileToMachineCode:aString forClass:aClass selector:selector inCategory:categoryArg 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   152
                             notifying:requestorArg install:install skipIfSame:skipIfSame silent:silent
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    "this is called to compile primitive code.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
     This is EXPERIMENTAL and going to be changed to raise an error,
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
     an redefined in subclasses which can do it (either by direct compilation, or by calling
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   156
     the external stc do do it)."
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
3042
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   158
    |handle oldMethod newMethod ok dllFileName|
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
    install ifFalse:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
        "/ cannot do it uninstalled. reason:
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
        "/ if it is loaded twice, the first version could be unloaded by
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
        "/ finalization, which would also unload the second version
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
        "/ (because the first unload would unload the second version too)
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
        ^ #CannotLoad
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    ].
2704
19bedf5ff15e changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2703
diff changeset
   167
    parserFlags isNil ifTrue:[
19bedf5ff15e changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2703
diff changeset
   168
        parserFlags := ParserFlags new
19bedf5ff15e changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2703
diff changeset
   169
    ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    parserFlags stcCompilation == #never ifTrue:[^ #CannotLoad].
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   171
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   172
    classToCompileFor := aClass.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   173
    requestor := requestorArg.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   174
    methodCategory := categoryArg.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   176
    self ensureModuleDirectoryExists.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   177
    self ensureExternalToolsArePresent ifFalse:[^ #CannotLoad].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   179
    theNonMetaclassToCompileFor := classToCompileFor theNonMetaclass.
1941
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   180
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   181
    self ensureSuperClassesAreLoadedOf:theNonMetaclassToCompileFor.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   182
    theNonMetaclassToCompileFor privateClassesSorted do:[:aPrivateClass |
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   183
        self ensureSuperClassesAreLoadedOf:aPrivateClass.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   184
    ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   185
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   186
    (classToCompileFor isNil 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   187
    or:[parserFlags allowExtensionsToPrivateClasses 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   188
    or:[classToCompileFor owningClass isNil]]) ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   189
        (requestor respondsTo:#packageToInstall) ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   190
            package := Class packageQuerySignal query.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   191
        ] ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   192
            package := requestor packageToInstall
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   193
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   194
    ] ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   195
        package := classToCompileFor owningClass package
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    [
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   199
        self generateSTSource:aString.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   200
        self setupCompilationCommandArguments.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   201
        ok := self compileToC.
3042
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   202
        ok ifFalse:[
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   203
            self reportCompilationErrorFor:stcPath.
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   204
            ^ #Error
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
3042
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   207
        parserFlags stcKeepSIntermediate ifTrue:[ self compileToS ].
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   208
        "/ now compile to machine code
ca88c2527ba5 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3013
diff changeset
   209
        ok := self compileToObj.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
        ok ifFalse:[
3005
dc025b2bb54e class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 2704
diff changeset
   211
            self reportCompilationErrorFor:ccPath.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
            ^ #Error
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
        originator activityNotification:''.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
        OperatingSystem removeFile:'errorOutput'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
         if required, make a shared or otherwise loadable object file for it
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
        originator activityNotification:'linking'.
2656
d3f4404f3e23 changed:
Stefan Vogel <sv@exept.de>
parents: 2649
diff changeset
   222
        dllFileName := ObjectFileLoader createLoadableObjectFor:(oFileName asFilename withoutSuffix name).
d3f4404f3e23 changed:
Stefan Vogel <sv@exept.de>
parents: 2649
diff changeset
   223
        dllFileName isNil ifTrue:[
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
            "/ something went wrong
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
            originator parseError:('link error: ' , ObjectFileLoader lastError) position:1.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
            ^ #CannotLoad
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
        ].
2656
d3f4404f3e23 changed:
Stefan Vogel <sv@exept.de>
parents: 2649
diff changeset
   228
        dllFileName asFilename exists ifFalse:[
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
            originator parseError:'link failed - cannot create machine code' position:1.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
            ^ #CannotLoad
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   233
        oldMethod := classToCompileFor compiledMethodAt:selector.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   234
        oldMethod notNil ifTrue:[package := oldMethod package].
3159
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   235
        install ifTrue:[
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   236
            (Smalltalk
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   237
                    changeRequest:#methodInClass
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   238
                    with:(Array with:classToCompileFor with:selector with:oldMethod)) ifFalse:[
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   239
                ^ #CannotLoad
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   240
            ].
697fcd52060b class: STCCompilerInterface
Stefan Vogel <sv@exept.de>
parents: 3069
diff changeset
   241
        ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
         load the method objectfile
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
        originator activityNotification:'loading'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
2656
d3f4404f3e23 changed:
Stefan Vogel <sv@exept.de>
parents: 2649
diff changeset
   248
        handle := ObjectFileLoader loadMethodObjectFile:dllFileName.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
        handle isNil ifTrue:[
2656
d3f4404f3e23 changed:
Stefan Vogel <sv@exept.de>
parents: 2649
diff changeset
   250
            OperatingSystem removeFile:dllFileName.
2185
cb311d08a486 changed #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2068
diff changeset
   251
            "catch, so that #CannotLoad processing is done"
3069
230e5da2ff5d class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3042
diff changeset
   252
            ParseError catch:[
2185
cb311d08a486 changed #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2068
diff changeset
   253
                originator parseError:'dynamic load of machine code failed' position:1.
cb311d08a486 changed #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2068
diff changeset
   254
            ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
            ^ #CannotLoad
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
        "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
         did it work ?
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
        "
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   261
        newMethod := classToCompileFor compiledMethodAt:selector.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
        "/ if install is false, we have to undo the install (which is always done, when loading machine code)
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
        install ifFalse:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
            oldMethod isNil ifTrue:[
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   266
                classToCompileFor removeSelector:selector
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
            ] ifFalse:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
                newMethod setPackage:oldMethod package.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   269
                classToCompileFor addSelector:selector withMethod:oldMethod.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   270
                oldMethod setPackage:package.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
            ]
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
        newMethod notNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
            handle method ~~ newMethod ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
                'Compiler [warning]: loaded method installed itself in another class' errorPrintCR.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
            newMethod source:aString string.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   280
            newMethod setPackage:package.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
"/            Project notNil ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
"/                newMethod package:(Project currentPackageName)
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
"/            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   285
    "/        classToCompileFor updateRevisionString.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
            install ifTrue:[
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   287
                classToCompileFor addChangeRecordForMethod:newMethod fromOld:oldMethod.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
                "/ kludge-sigh: must send change messages manually here (stc-loaded code does not do it)
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
                "/ see addMethod:... in ClassDescription
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   291
                classToCompileFor changed:#methodDictionary with:(Array with:selector with:oldMethod).
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   292
                Smalltalk changed:#methodInClass with:(Array with:classToCompileFor with:selector with:oldMethod).
2350
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   293
            ] ifFalse:[
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   294
                oldMethod := nil.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
1986
57913c678602 comment
Stefan Vogel <sv@exept.de>
parents: 1941
diff changeset
   297
            silent ifFalse:[
1941
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   298
                Transcript showCR:('    compiled: ', aClass name,' ',selector,' - machine code')
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
            ObjectMemory flushCaches.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
            handle method:newMethod.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
2350
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   304
            "/ check for obsolete compiled method code and unload the
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   305
            "/ corresponding ObjectFileHandle.
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   306
            "/ The old method with its source code is usually kept in the method history.
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   307
            "/ and will be recompiled on an undo
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
            ObjectFileLoader loadedObjectHandlesDo:[:anotherHandle |
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
                anotherHandle isMethodHandle ifTrue:[
2350
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   311
                    anotherHandle method == oldMethod ifTrue:[
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   312
                        "break association betwen old method, code and handle"
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   313
                        anotherHandle removeConnectedObjects.
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   314
                    ].
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   315
                    anotherHandle isObsolete ifTrue:[
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   316
                        anotherHandle unload.
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   317
                        anotherHandle removeUnusedObjectFile.
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   318
                    ].
16caba266df4 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Stefan Vogel <sv@exept.de>
parents: 2336
diff changeset
   319
                ].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
            ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
            ^ newMethod.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
3013
8f6ee079e44d class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3012
diff changeset
   324
        "/ OperatingSystem removeFile:moduleFileName.
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
        originator parseError:'dynamic load failed' position:1.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
        ^ #CannotLoad
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
    ] ensure:[
2703
2e966ec31082 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
   328
        parserFlags stcKeepSTIntermediate ifTrue:[
2e966ec31082 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
   329
            Transcript showCR:'keeping st file: ', stFileName asFilename pathName
2e966ec31082 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
   330
        ] ifFalse:[
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
            OperatingSystem removeFile:stFileName.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
            OperatingSystem removeFile:'errorOutput'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
        ].
2703
2e966ec31082 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
   334
        parserFlags stcKeepCIntermediate == true ifTrue:[
2e966ec31082 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
   335
            Transcript showCR:'keeping c file: ', cFileName asFilename pathName
2e966ec31082 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
   336
        ] ifFalse:[
2e966ec31082 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
   337
            (cFileName notNil and:[cFileName asFilename exists]) ifTrue:[cFileName asFilename delete].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
        ].
2703
2e966ec31082 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
   339
        parserFlags stcKeepOIntermediate == true ifTrue:[
2e966ec31082 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
   340
            Transcript showCR:'keeping o file: ', oFileName asFilename pathName
2e966ec31082 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
   341
        ] ifFalse:[
2e966ec31082 changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2658
diff changeset
   342
            (oFileName notNil and:[oFileName asFilename exists]) ifTrue:[oFileName asFilename delete].
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
        OperatingSystem isMSDOSlike ifTrue:[
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
"/            (mapFileName notNil and:[mapFileName asFilename exists]) ifTrue:[mapFileName asFilename delete].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
"/            (libFileName notNil and:[libFileName asFilename exists]) ifTrue:[libFileName asFilename delete].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
        ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
    ].
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
     |m|
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
     Object subclass:#Test
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
            instanceVariableNames:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
            classVariableNames:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
            poolDictionaries:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
            category:'tests'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
     m := ByteCodeCompiler
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
            compile:'foo ^ ''hello'''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
            forClass:Test
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
            inCategory:'tests'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
            notifying:nil
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
            install:false
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
            skipIfSame:false.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
     m inspect
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
     |m|
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
     Object subclass:#Test
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
            instanceVariableNames:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
            classVariableNames:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
            poolDictionaries:''
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
            category:'tests'.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
     m := ByteCodeCompiler
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
            compileToMachineCode:'foo %{ RETURN (_MKSMALLINT(1)); %}'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
            forClass:Test
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
            inCategory:'tests'
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
            notifying:nil
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
            install:false
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
            skipIfSame:false
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
            silent:false.
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
     m inspect
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
    "
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   386
    "Modified: / 14-09-1995 / 22:33:04 / claus"
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   387
    "Modified: / 19-03-1999 / 08:31:42 / stefan"
2704
19bedf5ff15e changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
Claus Gittinger <cg@exept.de>
parents: 2703
diff changeset
   388
    "Modified: / 17-09-2011 / 10:39:25 / cg"
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   389
! !
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   390
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   391
!STCCompilerInterface methodsFor:'machine code generation-helpers'!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   392
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   393
compileToC
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   394
    "compile st to C using stc"
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   395
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   396
    |command errorStream ok|
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   397
2658
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   398
    command := (self possiblyQuotedPath:stcPath) , ' ' , stcFlags 
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   399
                , ' -defdir=', (self possiblyQuotedPath:cFileName asFilename directory pathName).
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   400
    cFileName asFilename suffix = 'c' ifFalse:[
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   401
        command := command , ' -cSuffix=',cFileName asFilename suffix.
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   402
    ].
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   403
    command := command ,
2658
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   404
                ' -C ' , (self possiblyQuotedPath:stFileName asFilename pathName).
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   405
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   406
    errorStream := 'errorOutput' asFilename writeStream.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   407
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   408
    Verbose == true ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   409
        'executing: ' infoPrint. command infoPrintCR.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   410
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   411
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   412
    originator activityNotification:'compiling (stc)'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   413
    ok := OperatingSystem 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   414
                executeCommand:command 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   415
                inputFrom:nil
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   416
                outputTo:errorStream
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   417
                errorTo:errorStream
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   418
                onError:[:stat| 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   419
                            executionStatus := stat.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   420
                            false
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   421
                        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   422
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   423
    errorStream close.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   424
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   425
    cFileName asFilename exists ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   426
        ok ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   427
            'Compiler [info]: oops - system says stc failed - but c-file is there ...' infoPrintCR.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   428
            ok := true
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   429
        ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   430
    ] ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   431
        ok ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   432
            'Compiler [info]: oops - system says stc ok - but no c-file is there ...' infoPrintCR.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   433
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   434
        ok := false
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   435
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   436
    ^ ok
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   437
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   438
    "Created: / 07-11-2006 / 12:11:24 / cg"
2643
60d2bae2be58 comment/format in: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2491
diff changeset
   439
    "Modified: / 08-08-2011 / 22:12:01 / cg"
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   440
!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   441
2336
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   442
compileToExe
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   443
    "compile C to exe, using cc"
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   444
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   445
    |command errorStream ok|
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   446
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   447
    errorStream := 'errorOutput' asFilename newReadWriteStream.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   448
2658
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   449
    command := (self possiblyQuotedPath:ccPath) , ' ' , cFlags , ' -D__INCREMENTAL_COMPILE__ ' , (self possiblyQuotedPath:cFileName).
2336
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   450
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   451
    Verbose == true ifTrue:[
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   452
        'executing: ' infoPrint. command infoPrintCR.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   453
    ].
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   454
    originator activityNotification:'compiling (' , ccPath , ')'.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   455
    ok := OperatingSystem 
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   456
                executeCommand:command 
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   457
                inputFrom:nil
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   458
                outputTo:errorStream
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   459
                errorTo:errorStream
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   460
                onError:[:stat| 
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   461
                            executionStatus := stat.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   462
                            false
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   463
                ].
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   464
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   465
    ok ifFalse:[
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   466
        errorStream reset.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   467
        errorStream copyToEndInto:Transcript.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   468
    ].
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   469
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   470
    errorStream close.
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   471
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   472
    ^ ok
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   473
!
adaeb8836c48 added: #compileToExe
Claus Gittinger <cg@exept.de>
parents: 2335
diff changeset
   474
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   475
compileToObj
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   476
    "compile C to obj, using cc"
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   477
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   478
    |errorStream ok command ccDefine|
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   479
2195
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   480
    errorStream := 'errorOutput' asFilename newReadWriteStream.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   481
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   482
    "/ bcc does not like -D__BORLANDC__ (needs to be set to a version, such as 0x0505
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   483
    "/ others do not need it (is already predefined in the compiler)
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   484
    "/ ccDefine := ' -D',ParserFlags usedCompilerDefine.
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   485
    ccDefine := ''.
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   486
3010
7970294627a3 flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents: 3005
diff changeset
   487
    ParserFlags useBorlandC ifTrue:[
7970294627a3 flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents: 3005
diff changeset
   488
        "Note: Windows/bcc32 does not understand a space between -o and filename"
7970294627a3 flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents: 3005
diff changeset
   489
        "/ cg: I guess, this does not work for visual-c
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   490
        command := (self possiblyQuotedPath:ccPath) , ' ' , cFlags , ccDefine,' -D__INCREMENTAL_COMPILE__ -o', (self possiblyQuotedPath:oFileName), ' -c ' , (self possiblyQuotedPath:cFileName).
3010
7970294627a3 flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents: 3005
diff changeset
   491
    ] ifFalse:[
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   492
        command := (self possiblyQuotedPath:ccPath) , ' ' , cFlags , ccDefine,' -D__INCREMENTAL_COMPILE__ -o ', (self possiblyQuotedPath:oFileName), ' -c ' , (self possiblyQuotedPath:cFileName).
3010
7970294627a3 flag settings for 64bit mingw
Claus Gittinger <cg@exept.de>
parents: 3005
diff changeset
   493
    ].
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   494
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   495
    Verbose == true ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   496
        'executing: ' infoPrint. command infoPrintCR.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   497
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   498
    originator activityNotification:'compiling (' , ccPath , ')'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   499
    ok := OperatingSystem 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   500
                executeCommand:command 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   501
                inputFrom:nil
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   502
                outputTo:errorStream
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   503
                errorTo:errorStream
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   504
                onError:[:stat| 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   505
                            executionStatus := stat.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   506
                            false
2195
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   507
                ].
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   508
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   509
    ok ifFalse:[
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   510
        errorStream reset.
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   511
        errorStream copyToEndInto:Transcript.
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   512
    ].
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   513
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   514
    errorStream close.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   515
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   516
    oFileName asFilename exists ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   517
        ok ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   518
            'Compiler [info]: system says compile failed - but o-file is there ...' infoPrintCR.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   519
            ok := true
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   520
        ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   521
    ] ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   522
        ok ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   523
            'Compiler [info]: system says compile ok - but no o-file is there ...' infoPrintCR.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   524
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   525
        ok := false
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   526
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   527
    ^ ok
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   528
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   529
    "Created: / 07-11-2006 / 12:14:51 / cg"
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   530
!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   531
2491
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   532
compileToS
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   533
    "compile C to assembler, using cc"
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   534
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   535
    |command errorStream ok|
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   536
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   537
    errorStream := 'errorOutput' asFilename newReadWriteStream.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   538
2658
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   539
    command := (self possiblyQuotedPath:ccPath) , ' ' , cFlags , ' -D__INCREMENTAL_COMPILE__ -S ' , (self possiblyQuotedPath:cFileName).
2491
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   540
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   541
    Verbose == true ifTrue:[
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   542
        'executing: ' infoPrint. command infoPrintCR.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   543
    ].
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   544
    originator activityNotification:'compiling (' , ccPath , ')'.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   545
    ok := OperatingSystem 
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   546
                executeCommand:command 
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   547
                inputFrom:nil
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   548
                outputTo:errorStream
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   549
                errorTo:errorStream
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   550
                onError:[:stat| 
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   551
                            executionStatus := stat.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   552
                            false
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   553
                ].
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   554
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   555
    ok ifFalse:[
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   556
        errorStream reset.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   557
        errorStream copyToEndInto:Transcript.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   558
    ].
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   559
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   560
    errorStream close.
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   561
    ^ ok
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   562
!
2d549088a8ea added: #compileToS
Michael Beyl <mb@exept.de>
parents: 2467
diff changeset
   563
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   564
ensureExternalToolsArePresent
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   565
    (stcPath := self incrementalStcPath) isNil ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   566
        originator parseError:'no stc compiler available - cannot create machine code' position:1.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   567
        ^ false
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   568
    ].
2649
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   569
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   570
    "make it absolute, so that we are immune to directory changes"
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   571
    stcPath := stcPath asFilename pathName.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   572
    (ccPath := parserFlags ccPath) isNil ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   573
        originator parseError:'no cc compiler available - cannot create machine code' position:1.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   574
        ^ false
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   575
    ].
2649
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   576
    "make it absolute, so that we are immune to directory changes"
0e257259566f changed:
Stefan Vogel <sv@exept.de>
parents: 2647
diff changeset
   577
    ccPath := ccPath asFilename pathName.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   578
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   579
    (ObjectFileLoader notNil and:[ObjectFileLoader canLoadObjectFiles]) ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   580
        originator parseError:'no dynamic loader configured - cannot create machine code' position:1.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   581
        ^ false
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   582
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   583
    ^ true
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   584
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   585
    "Created: / 07-11-2006 / 12:31:48 / cg"
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   586
!
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   587
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   588
ensureModuleDirectoryExists
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   589
    |mP t s|
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   590
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   591
    (mP := parserFlags stcModulePath asFilename) exists ifFalse:[
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   592
        mP makeDirectory
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   593
    ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   594
    (mP isDirectory and:[ mP isReadable and:[ mP isWritable ] ]) ifFalse:[
3069
230e5da2ff5d class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3042
diff changeset
   595
        ParseError raiseErrorString:('No access to temporary module directory: ' , mP pathName).
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   596
    ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   597
    "/ create a small README there ...
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   598
    
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   599
    (t := mP construct:'README') exists ifFalse:[
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   600
        s := t writeStream.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   601
        s 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   602
            nextPutAll:'This temporary ST/X directory contains machine code for
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   603
accepted methods with embedded C-code 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   604
(i.e. dynamic compiled code for inline-C methods).
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   605
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   606
Files here are not automatically removed, since ST/X 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   607
cannot determine if any (other) snapshot image still 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   608
requires a file here.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   609
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   610
Please be careful when removing files here - a snapshot
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   611
image which was saved with accepted embedded C-code
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   612
may not be able to restart correctly if you remove a
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   613
required file.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   614
Also, when you export a snapshot image for execution
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   615
on another machine, make certain that the required
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   616
module-files are also present there.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   617
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   618
You should periodically clean dead entries here.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   619
i.e. remove files, when you are certain that none
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   620
of your snapshot images refers to any module here.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   621
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   622
See the launchers File-Modules dialog for a list of
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   623
modules which are still required by your running image.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   624
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   625
With kind regards - your ST/X.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   626
'.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   627
        s close.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   628
    ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   629
!
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   630
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   631
ensureSuperClassesAreLoadedOf:aClass
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   632
    |supers|
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   633
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   634
    supers := aClass allSuperclasses.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   635
    supers reverseDo:[:cls|
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   636
        cls isLoaded ifFalse:[
3069
230e5da2ff5d class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3042
diff changeset
   637
            ParseError raiseErrorString:'Cannot stc-compile (Some superclass is unloaded)'.
1670
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   638
        ]
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   639
    ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   640
!
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   641
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   642
fileOutAllDefinitionsOf:aClass to:aStream rememberIn:definedClasses
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   643
    |defineAction|
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   644
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   645
    defineAction := 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   646
        [:cls|
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   647
            (definedClasses includes:cls) ifFalse:[
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   648
                cls 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   649
                    basicFileOutDefinitionOn:aStream 
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   650
                    withNameSpace:false withPackage:false
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   651
                    syntaxHilighting:false.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   652
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   653
                aStream nextPut:(aStream class chunkSeparator); cr.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   654
                definedClasses add:cls.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   655
            ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   656
        ].
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   657
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   658
    aClass allSuperclasses reverseDo:defineAction.
08e3e0723a60 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1669
diff changeset
   659
    defineAction value:aClass.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   660
!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   661
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   662
generateSTSource:aString 
2647
a47876ae33fd changed: #generateSTSource:
Stefan Vogel <sv@exept.de>
parents: 2646
diff changeset
   663
    |stream definedClasses sep className modulesDir|
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   664
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   665
    "/ generate a unique name, consisting of my processID and a sequence number
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   666
    "/ the processId is added to allow filein of modules from different
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   667
    "/ lifes
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   668
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   669
    SequenceNumber := (SequenceNumber ? 0) + 1.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   670
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   671
    initName := 'm_' , OperatingSystem getProcessId printString, '_' , SequenceNumber printString.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   672
2646
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   673
"/    Smalltalk isSmalltalkDevelopmentSystem ifTrue:[
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   674
"/        modulesParentDir := Filename currentDirectory. 
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   675
"/    ] ifFalse:[
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   676
"/        modulesParentDir := Filename tempDirectory. 
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   677
"/    ].
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   678
"/    modulesDir := modulesParentDir construct:'modules'. 
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   679
    modulesDir := ParserFlags stcModulePath.
2647
a47876ae33fd changed: #generateSTSource:
Stefan Vogel <sv@exept.de>
parents: 2646
diff changeset
   680
    stFileName := (modulesDir asFilename construct:(initName , '.st')) name. 
2646
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   681
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   682
    [
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   683
        stream := stFileName asFilename writeStream.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   684
    ] on:FileStream openErrorSignal do:[:ex|
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   685
        originator parseError:'cannot create temporary sourcefile for compilation'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   686
        ^ #CannotLoad
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   687
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   688
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   689
    definedClasses := IdentitySet new.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   690
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   691
    sep := stream class chunkSeparator.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   692
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   693
    Class fileOutNameSpaceQuerySignal answer:true
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   694
    do:[
2467
a7ed431694a2 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2461
diff changeset
   695
        theNonMetaclassToCompileFor realSharedPoolNames do:[:eachPoolname |
2067
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   696
            |pool|
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   697
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   698
            pool := Smalltalk at:eachPoolname.
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   699
            self 
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   700
                fileOutAllDefinitionsOf:pool 
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   701
                to:stream 
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   702
                rememberIn:definedClasses.
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   703
        ].
6204fefb44a3 must also file-out the definition of sharedPools
Claus Gittinger <cg@exept.de>
parents: 2026
diff changeset
   704
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   705
        self 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   706
            fileOutAllDefinitionsOf:theNonMetaclassToCompileFor 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   707
            to:stream 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   708
            rememberIn:definedClasses.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   709
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   710
        theNonMetaclassToCompileFor privateClassesSorted do:[:aPrivateClass |
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   711
            self 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   712
                fileOutAllDefinitionsOf:aPrivateClass 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   713
                to:stream 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   714
                rememberIn:definedClasses.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   715
        ].
2195
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   716
"/        theNonMetaclassToCompileFor fileOutPrimitiveDefinitionsOn:stream.
2026
652850012b15 remove dead code
Stefan Vogel <sv@exept.de>
parents: 1986
diff changeset
   717
"/ If a method uses a static primitive function... - but this doesn't work
2195
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   718
"/ Yes it does work, but primitive functions have to be strictly static!!
2996fe27c2f8 Add primitive functions when compiling
Stefan Vogel <sv@exept.de>
parents: 2185
diff changeset
   719
        theNonMetaclassToCompileFor fileOutPrimitiveSpecsOn:stream.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   720
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   721
2026
652850012b15 remove dead code
Stefan Vogel <sv@exept.de>
parents: 1986
diff changeset
   722
"/    stream cr.
652850012b15 remove dead code
Stefan Vogel <sv@exept.de>
parents: 1986
diff changeset
   723
"/    stream nextPutLine:'"{ Package: ''' , package , ''' }"'.
652850012b15 remove dead code
Stefan Vogel <sv@exept.de>
parents: 1986
diff changeset
   724
"/    stream cr.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   725
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   726
    stream nextPut:sep.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   727
    className := theNonMetaclassToCompileFor name.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   728
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   729
    stream nextPutAll:className.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   730
    classToCompileFor isMeta ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   731
        stream nextPutAll:' class'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   732
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   733
    stream nextPutAll:' methodsFor:'''; nextPutAll:methodCategory; nextPutAll:''''.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   734
    stream nextPut:sep; cr.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   735
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   736
    stream nextPutLine:'"{ Line: 0 }"'; 
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   737
           nextChunkPut:aString;
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   738
           space; nextPut:sep.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   739
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   740
    stream close.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   741
2646
de9d7a6e6315 changed: #generateSTSource:
Claus Gittinger <cg@exept.de>
parents: 2644
diff changeset
   742
    "Modified: / 08-08-2011 / 23:23:10 / cg"
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   743
!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   744
2658
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   745
possiblyQuotedPath:aPath
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   746
    (aPath includes:$ ) ifTrue:[
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   747
        (aPath startsWith:'"') ifFalse:[
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   748
            ^ '"',aPath,'"'
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   749
        ]
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   750
    ].
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   751
    ^ aPath
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   752
!
92f1a346dbeb added: #possiblyQuotedPath:
Claus Gittinger <cg@exept.de>
parents: 2656
diff changeset
   753
3005
dc025b2bb54e class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 2704
diff changeset
   754
reportCompilationErrorFor:aCommand
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   755
    |eMsg errorMessages lNr|
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   756
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   757
    (executionStatus notNil and:[executionStatus couldNotExecute]) ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   758
        eMsg := 'oops, no STC - cannot create machine code'
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   759
    ] ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   760
        errorMessages := 'errorOutput' asFilename contents.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   761
        OperatingSystem removeFile:'errorOutput'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   762
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   763
        errorMessages notNil ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   764
            errorMessages := errorMessages reject:[:line | line includesString:'Warning:'].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   765
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   766
            errorMessages size > 20 ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   767
                errorMessages := errorMessages select:[:line | line asLowercase startsWith:'error'].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   768
                errorMessages size > 20 ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   769
                    errorMessages := (errorMessages copyTo:20) copyWith:'... more messages skipped'
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   770
                ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   771
            ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   772
"/                    errorMessages := errorMessages collect:[:line |
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   773
"/                        (line startsWith:(stFileName , ':')) ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   774
"/                            'Line: ' , (line copyFrom:(stFileName size + 2))
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   775
"/                        ] ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   776
"/                            line
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   777
"/                        ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   778
"/                      ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   779
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   780
        errorMessages isNil ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   781
            errorMessages := #('')
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   782
        ].
3005
dc025b2bb54e class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 2704
diff changeset
   783
        errorMessages := (Array with:'Failed to execute: "', aCommand,'"') , errorMessages.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   784
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   785
        "/ try to extract a line number"
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   786
        (errorMessages contains:[:line | line includesString:'Borland']) ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   787
            |i i2 s|
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   788
            i := errorMessages findFirst:[:l | l startsWith:(cFileName,':')].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   789
            i ~~ 0 ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   790
                ((errorMessages at:i+1) startsWith:'Error') ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   791
                    i2 := (errorMessages at:i+1) indexOfSubCollection:(stFileName).
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   792
                    i2 ~~ 0 ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   793
                        s := (errorMessages at:i+1) copyFrom:(i2+stFileName size+1).
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   794
                        s := s readStream.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   795
                        lNr := Integer readFrom:s.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   796
                        s skipSeparators.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   797
                    ].    
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   798
                ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   799
            ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   800
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   801
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   802
        errorMessages isEmpty ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   803
            eMsg := 'Error during compilation:\\Unspecified error (no output)' withCRs
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   804
        ] ifFalse:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   805
            eMsg := 'Error during compilation:\\' withCRs ,
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   806
                    (errorMessages asStringCollection asString).
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   807
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   808
    ].
2461
89458faaeeb3 changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents: 2350
diff changeset
   809
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   810
    originator activityNotification:''.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   811
3069
230e5da2ff5d class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3042
diff changeset
   812
    ParseError new
2461
89458faaeeb3 changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents: 2350
diff changeset
   813
        lineNumber:lNr;
89458faaeeb3 changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents: 2350
diff changeset
   814
        errorMessage:eMsg;
89458faaeeb3 changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents: 2350
diff changeset
   815
        raise.
89458faaeeb3 changed: #reportCompilationError
Stefan Vogel <sv@exept.de>
parents: 2350
diff changeset
   816
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   817
    "Created: / 07-11-2006 / 12:29:04 / cg"
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   818
!
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   819
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   820
setupCompilationCommandArguments
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   821
    |stFn mapFileName libFileName def libDir incDir incDirArg defs incl opts|
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   822
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   823
    parserFlags isNil ifTrue:[ parserFlags := ParserFlags new].
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   824
1941
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   825
    stFn := stFileName asFilename.
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   826
    oFileName := stFn nameWithoutSuffix , (ObjectFileLoader objectFileExtension).
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   827
    cFileName := (stFn withSuffix:'c') name. 
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   828
"/    ParserFlags useBorlandC ifTrue:[
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   829
"/        cFileName := (stFn withSuffix:'sc') name. 
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   830
"/    ].
1941
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   831
    mapFileName := (stFn withSuffix:'map') name. 
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   832
    libFileName := (stFn withSuffix:'lib') name. 
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   833
    oFileName asFilename delete.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   834
    cFileName asFilename delete.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   835
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   836
    "/ stcFlags := '-commonSymbols +sharedLibCode +newIncremental -E:errorOutput -N' , initName .
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   837
    stcFlags := '+newIncremental -E:errorOutput'.
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   838
    initName notNil ifTrue:[
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   839
        stcFlags := stcFlags,' -N' , initName .
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   840
    ].
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   841
    cFlags := OperatingSystem getOSDefine.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   842
    cFlags isNil ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   843
        cFlags := ''
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   844
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   845
    (def := OperatingSystem getCPUDefine) notNil ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   846
        cFlags := cFlags , ' ' , def
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   847
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   848
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   849
    (defs := parserFlags stcCompilationDefines) notNil ifTrue:[
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   850
        cFlags := cFlags , ' ' , defs
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   851
    ].
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   852
    (incl := parserFlags stcCompilationIncludes) notNil ifTrue:[
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   853
        stcFlags := incl , ' ' , stcFlags.
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   854
        cFlags := cFlags , ' ' , incl.
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   855
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   856
        "/ if STX_LIBDIR is defined, and not in passed argument,
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   857
        "/ add it here.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   858
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   859
        libDir := OperatingSystem getEnvironment:'STX_LIBDIR'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   860
        (libDir notNil and:[libDir asFilename exists]) ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   861
            incDir := libDir asFilename construct:'include'.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   862
            incDir exists ifTrue:[
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   863
                incDirArg := '-I' , incDir pathName.
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   864
                (incl asCollectionOfWords includes:incDirArg) ifFalse:[
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   865
                    stcFlags := stcFlags , ' ' , incDirArg.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   866
                    cFlags := cFlags , ' ' , incDirArg.
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   867
                ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   868
            ]
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   869
        ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   870
    ].
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   871
    (opts := parserFlags stcCompilationOptions) notNil ifTrue:[
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   872
        stcFlags := opts , ' ' , stcFlags
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   873
    ].
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   874
    (opts := parserFlags ccCompilationOptions) notNil ifTrue:[
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   875
        cFlags := cFlags , ' ' , opts
1939
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   876
    ].
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   877
babab41fc8e8 code cleanup
Claus Gittinger <cg@exept.de>
parents: 1899
diff changeset
   878
    "Created: / 07-11-2006 / 12:24:47 / cg"
1941
941810becd2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1939
diff changeset
   879
    "Modified: / 07-11-2006 / 13:58:54 / cg"
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   880
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   881
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   882
!STCCompilerInterface class methodsFor:'documentation'!
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   883
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   884
version
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   885
    ^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.35 2013-05-17 14:16:22 cg Exp $'
2335
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   886
!
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   887
70a690b780f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2195
diff changeset
   888
version_CVS
3170
fccd602cb081 class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 3159
diff changeset
   889
    ^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.35 2013-05-17 14:16:22 cg Exp $'
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   890
! !
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   891
3005
dc025b2bb54e class: STCCompilerInterface
Claus Gittinger <cg@exept.de>
parents: 2704
diff changeset
   892
1669
fc13f4636125 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   893
STCCompilerInterface initialize!