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