PmCleanSystem.dcl 6.67 KB
Newer Older
Diederik van Arkel's avatar
Diederik van Arkel committed
1
2
3
4
definition module PmCleanSystem

// Interface module for calling the CLEAN compiler, code generator and linker

5
import StdFile, StdMaybe
Diederik van Arkel's avatar
Diederik van Arkel committed
6
7
8
9
import StdPathname
import UtilStrictLists
import PmCompilerOptions
import PmTypes
10
import PmCallBack
Diederik van Arkel's avatar
Diederik van Arkel committed
11

12
standardStaticLibraries	:: !Processor !LinkMethod -> List String
13
standardObjectFiles		:: !Bool !Bool !Processor !Bool -> List String
Diederik van Arkel's avatar
Diederik van Arkel committed
14
15
16

getLibs :: ![String] !*Files -> (!(![String],![String]),!*Files)

17
18
19
20
:: CompilerProcessIds

NoCompilerProcessIds :: CompilerProcessIds

21
ClearCompilerCache :: !String !String !.a -> (!Int,!.a)
22
ClearCompilerCaches :: !CompilerProcessIds !.a -> (!Int,!.a)
23
QuitCleanCompiler :: !Bool !CompilerProcessIds !*World -> *World
Diederik van Arkel's avatar
Diederik van Arkel committed
24

25
26
//::	CompileClearCache	= ClearCache | Don`tClearCache
//instance == CompileClearCache
Diederik van Arkel's avatar
Diederik van Arkel committed
27
28
29
30
31
32
33
34
35
36
37
38
39

::	CompileOrCheckSyntax	= SyntaxCheck | Compilation
instance == CompileOrCheckSyntax

::	CodeGenerateAsmOrCode	= AsmGeneration | CodeGeneration
instance == CodeGenerateAsmOrCode

::	CompilerMsg
	= 	CompilerOK
	| 	SyntaxError
	| 	Patherror Pathname
instance == CompilerMsg

Diederik van Arkel's avatar
Diederik van Arkel committed
40
::	WindowFun env :== ([String]) -> env -> env
Diederik van Arkel's avatar
Diederik van Arkel committed
41

42
43
44
45
46
:: ProjectCompilerOptions = {
	pco_memory_profiling :: !Bool,
	pco_time_profiling :: !Bool,
	pco_desc_exl :: !Bool,
	pco_dynamics :: !Bool,
47
	pco_generic_fusion :: !Bool,
48
49
50
	pco_link_dynamic :: !Bool
   }

Diederik van Arkel's avatar
Diederik van Arkel committed
51
52
53
54
Compile ::						// Compiles the given file:
	!String						// compiler exe name and options
								// !! should be full path so that cocl generates diagnostics in logical place...
								// should be quoted if required
55
	!Bool
Diederik van Arkel's avatar
Diederik van Arkel committed
56
57
58
59
	!Bool						// write module times to abc file
	!(WindowFun *env)			// error display fun
	!(WindowFun *env)			// types display fun
	!CompileOrCheckSyntax		// check syntax only?
60
	!ModuleDirAndName
Diederik van Arkel's avatar
Diederik van Arkel committed
61
62
	!Pathname					// full .icl pathname of module to be compiled
	!(List Pathname)			// list of paths where compiler can find imported .dcl files
63
	!ProjectCompilerOptions
Diederik van Arkel's avatar
Diederik van Arkel committed
64
65
	!CompilerOptions			// compiler options
	!Pathname					// startup directory
66
	!CompilerProcessIds
Diederik van Arkel's avatar
Diederik van Arkel committed
67
68
	!*env						// state
	->
69
	(!Pathname					// .abc pathname of generated code
Diederik van Arkel's avatar
Diederik van Arkel committed
70
71
72
73
//					Note: on the macintosh the .abc file is generated in the standard Clean System
//					Files Folder. On Unix, however, the location of the .abc depends on the user
//					settings.
	,!CompilerMsg				// indication whether compilation was successfull
74
75
	,!CompilerProcessIds
	,!*env						// state
Diederik van Arkel's avatar
Diederik van Arkel committed
76
77
78
79
80
81
	) | FileEnv env

CodeGen	::						// Generates code for the given file:
	!String						// generator exe name and options
								// !! should be full path so that cg generates diagnostics in logical place...
								// should be quoted if required
82
	!Bool
83
	!(WindowFun *GeneralSt)		// error display fun
Diederik van Arkel's avatar
Diederik van Arkel committed
84
85
	!CodeGenerateAsmOrCode		// generate assembly only?
	!Pathname					// full .abc pathname of module to be compiled
86
	!Pathname					// full object pathname of module to be compiled
Diederik van Arkel's avatar
Diederik van Arkel committed
87
88
	!Bool						// time profiling...
	!CodeGenOptions				// code generator options
89
	!Processor					// target processor
Diederik van Arkel's avatar
Diederik van Arkel committed
90
91
	!ApplicationOptions			// application options
	!Pathname					// startup directory
92
	!CompilerProcessIds
93
	!*GeneralSt					// state
Diederik van Arkel's avatar
Diederik van Arkel committed
94
	->
95
	( !Pathname					// full pathname of generated object file
96
	, !Bool						// success status
97
	, !CompilerProcessIds
98
	, !*GeneralSt				// state
Diederik van Arkel's avatar
Diederik van Arkel committed
99
100
101
102
103
104
	)

Link ::							// Links the given file:
	!String						// linker exe name
								// !! should be full path so that linker generates diagnostics in logical place...
								// this is quoted by the Link function because it first needs to decompose it...
105
	!(WindowFun *GeneralSt)		// error display fun
Diederik van Arkel's avatar
Diederik van Arkel committed
106
107
108
109
110
111
112
113
	!Pathname					// full pathname of the executable
	!ApplicationOptions			// application options
	!Pathname					// options pathname
	!(List Pathname)			// dynamic library file names
	!(List Pathname)			// object file names
	!(List Pathname)			// static library file names
	!Bool						// link statically?
	!Bool						// generate relocations?
114
	!Bool						// generate symbol table?
Diederik van Arkel's avatar
Diederik van Arkel committed
115
116
117
118
119
120
	!Bool						// generate link map?
	!Bool						// link in resources?
	!String						// source of resources to link in
	!Bool						// generate dll?
	!String						// name of file containing symbols to be exported from dll
	!Pathname					// startup directory
Diederik van Arkel's avatar
Diederik van Arkel committed
121
	!String						// path to dynamic linker
122
	!Processor					// target processor
123
	!Bool						// 64 bit target processor
124
	!*GeneralSt					// state
Diederik van Arkel's avatar
Diederik van Arkel committed
125
	->
126
	( !*GeneralSt				// state
Diederik van Arkel's avatar
Diederik van Arkel committed
127
128
	, !Bool						// success status
	)
Diederik van Arkel's avatar
Diederik van Arkel committed
129
/*
130
DynLink :: !String !String !String !*GeneralSt -> (Bool,*GeneralSt)
Diederik van Arkel's avatar
Diederik van Arkel committed
131
*/
132
/*
Diederik van Arkel's avatar
Diederik van Arkel committed
133
134
135
136
137
138
139
140
141
Execute	::						// Executes the given application
	!(WindowFun *env)			// error display fun
	!Pathname					// full pathname of the application
	!ApplicationOptions			// application options (only need the console flag)
	*env						// state
	->
	( *env						// state
	, !Bool						// success status
	)
142
*/
Diederik van Arkel's avatar
Diederik van Arkel committed
143
144
145
146
147
148
149
150
151
152
153
154
155
156
Execute`	::	!String !*env -> (!Bool,!Int,!*env)


:: ThreadId
	:==	Int

CompileStartCommand ::
	!String
	!Bool						// write module times to abc file
	!(WindowFun *env)
	!CompileOrCheckSyntax
	!Pathname
	!(List Pathname)
	!Int
157
	!ProjectCompilerOptions
Diederik van Arkel's avatar
Diederik van Arkel committed
158
159
	!CompilerOptions
	!Pathname
160
	!CompilerProcessIds
Diederik van Arkel's avatar
Diederik van Arkel committed
161
	!*env
162
	-> (!Bool,!CompilerProcessIds,!*env) | FileEnv env
163
CompileHandleExitCode :: !Int !String !String !Int !(WindowFun *env) !(WindowFun *env) !ModuleDirAndName
164
				!ListTypes !*env -> (!Pathname,!CompilerMsg,!*env) | FileEnv env
Diederik van Arkel's avatar
Diederik van Arkel committed
165
166
167

:: CompilePollCompletedResult = NoFinishedCompiler | UnknownFinishedCompiler | FinishedCompiler !Int !Int

168
CompilePollCompleted :: !CompilerProcessIds !*env -> (!CompilePollCompletedResult, !*env) | FileEnv env
Diederik van Arkel's avatar
Diederik van Arkel committed
169
170
171

:: CompilingInfo

Diederik van Arkel's avatar
Diederik van Arkel committed
172
InitCompilingInfo :: *CompilingInfo
Diederik van Arkel's avatar
Diederik van Arkel committed
173
174
175
176
177
178
179
180
181

ExitCleanCompiler :: !*(!*CompilingInfo,*env) -> *(!*CompilingInfo,*env)

CompilePersistent ::
	!String					// cocl
	!Bool						// write module times to abc file
	!(WindowFun *env)		// errwin
	!(WindowFun *env)		// typewin
	!CompileOrCheckSyntax	// compileOrCheckSyntax
182
	!ModuleDirAndName
Diederik van Arkel's avatar
Diederik van Arkel committed
183
	!(List Pathname)		// paths
184
	!ProjectCompilerOptions
Diederik van Arkel's avatar
Diederik van Arkel committed
185
186
187
188
189
190
191
	!CompilerOptions		// compileroptions
	!Pathname				// startupdir
	!*CompilingInfo			// compiler state
	!*env					// env
	-> (!*CompilingInfo,!(!*env, !Pathname, !CompilerMsg))
	| FileEnv env

192
StartCodeGenerator	::	!String !(WindowFun *GeneralSt) !CodeGenerateAsmOrCode !Pathname !Int !Bool !CodeGenOptions !Processor !ApplicationOptions !Pathname !CompilerProcessIds !*GeneralSt -> (!Bool,!Pathname,!CompilerProcessIds,!*GeneralSt)
193
SendRepeatResult :: !Int !.a -> (!Int,!.a)
194
195

DelayEventLoop :: !.ps -> .ps
196
197
198
199
200

:: StartedCodeGenerator

start_code_generator ::	!String !(WindowFun *GeneralSt) !Pathname !Int !Bool !CodeGenOptions !Processor !Pathname !*GeneralSt
						-> (!Bool,!Int/*HANDLE*/,!StartedCodeGenerator,!*GeneralSt)
201
202
finish_code_generator :: !Int/*HANDLE*/ !StartedCodeGenerator !Int !(WindowFun *GeneralSt) !*GeneralSt -> (!Bool,!*GeneralSt)
wait_for_finished_code_generator :: !{#Int} !*GeneralSt -> (!Int,!Int,!*GeneralSt);