PmTypes.icl 10.7 KB
Newer Older
Diederik van Arkel's avatar
Diederik van Arkel committed
1 2
implementation module PmTypes

3
// The types for the Project Manager
Diederik van Arkel's avatar
Diederik van Arkel committed
4 5

import StdBool, StdInt
6
import UtilStrictLists
7
from UtilNewlinesFile import :: NewlineConvention(..)
Diederik van Arkel's avatar
Diederik van Arkel committed
8
import PmCompilerOptions
9
from StdPathname import :: Pathname
Diederik van Arkel's avatar
Diederik van Arkel committed
10
import StdFile
Diederik van Arkel's avatar
Diederik van Arkel committed
11
import Platform
Diederik van Arkel's avatar
Diederik van Arkel committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

::	Modulename			:== String

// Unexpected :: .a {#Char} -> .a
Unexpected message defaultValue
	:== UnexpectedEvalBefore defaultValue (UnexpectedReport message)

UnexpectedEvalBefore :: !.a !.b -> .a
UnexpectedEvalBefore defaultValue _
	=	defaultValue

Don`tCareValue :== 0

UnexpectedReport :: !{#Char} -> Int
UnexpectedReport message
	=	UnexpectedEvalBefore Don`tCareValue (fwrites message stderr)

UnexpectedConstructor :: !{#Char} !{#Char} !.a -> .a
UnexpectedConstructor typeName string defaultValue
	=	Unexpected ( "fromString (" +++ typeName +++ "): unknown value (" +++ string +++ ")\n") defaultValue

//--

Diederik van Arkel's avatar
Diederik van Arkel committed
35 36 37 38 39 40 41 42 43 44
::	Processor
	= CurrentProcessor
	| MC68000
	| MC68020
	| MC68020_and_68881
	| PowerPC_Classic
	| PowerPC_Carbon
	| PowerPC_MachO
	| I386

45 46 47 48 49 50 51
DefaultProcessor :: Processor
DefaultProcessor = PlatformDependant I386 PowerPC_Carbon

PlatformProcessors :: [Processor]
PlatformProcessors = PlatformDependant
	[I386]
	[PowerPC_Classic,PowerPC_Carbon,PowerPC_MachO]
Diederik van Arkel's avatar
Diederik van Arkel committed
52 53 54 55 56 57 58 59 60 61

ProcessorSuffix :: !Processor -> String
ProcessorSuffix CurrentProcessor	= ProcessorSuffix DefaultProcessor
ProcessorSuffix MC68000				= ".obj0"
ProcessorSuffix MC68020				= ".obj1"
ProcessorSuffix MC68020_and_68881	= ".obj2"
ProcessorSuffix PowerPC_Classic		= ".cxo"
ProcessorSuffix PowerPC_Carbon		= ".xo"
ProcessorSuffix PowerPC_MachO		= ".o"
ProcessorSuffix I386				= ".o"
Diederik van Arkel's avatar
Diederik van Arkel committed
62 63 64

instance == Processor
where
65
	(==) :: !Processor !Processor -> Bool
Diederik van Arkel's avatar
Diederik van Arkel committed
66 67 68 69 70 71 72 73 74
	(==) CurrentProcessor CurrentProcessor		=	True
	(==) MC68000 MC68000						=	True
	(==) MC68020 MC68020						=	True
	(==) MC68020_and_68881 MC68020_and_68881	=	True
	(==) PowerPC_Classic PowerPC_Classic		=	True
	(==) PowerPC_Carbon PowerPC_Carbon			=	True
	(==) PowerPC_MachO PowerPC_MachO			=	True
	(==) I386 I386								=	True
	(==) _ _									=	False
Diederik van Arkel's avatar
Diederik van Arkel committed
75 76 77

instance fromString Processor
where
78
	fromString :: !{#Char} -> Processor
Diederik van Arkel's avatar
Diederik van Arkel committed
79 80 81 82 83 84 85 86 87
	fromString "CurrentProcessor"		=	CurrentProcessor
	fromString "MC68000"				=	MC68000
	fromString "MC68020"				=	MC68020
	fromString "MC68020_and_68881"		=	MC68020_and_68881
	fromString "PowerPC_Classic"		=	PowerPC_Classic
	fromString "PowerPC_Carbon"			=	PowerPC_Carbon
	fromString "PowerPC_MachO"			=	PowerPC_MachO
	fromString "I386"					=	I386
	fromString string					=	UnexpectedConstructor "Processor" string CurrentProcessor
Diederik van Arkel's avatar
Diederik van Arkel committed
88 89 90

instance toString Processor
where
91
	toString :: !Processor -> {#Char}
Diederik van Arkel's avatar
Diederik van Arkel committed
92 93 94 95 96 97 98 99
	toString MC68000				=	"MC68000"
	toString MC68020				=	"MC68020"
	toString MC68020_and_68881		=	"MC68020_and_68881"
	toString PowerPC_Classic		=	"PowerPC_Classic"
	toString PowerPC_Carbon			=	"PowerPC_Carbon"
	toString PowerPC_MachO			=	"PowerPC_MachO"
	toString I386					=	"I386"
	toString CurrentProcessor		=	"CurrentProcessor"
Diederik van Arkel's avatar
Diederik van Arkel committed
100 101 102 103 104 105 106 107 108 109

:: ModInfoAndName =
	{
		info	:: ModInfo,
		name	:: {#Char}
	}

::	ModInfo	=
	{ dir				:: !String				// !Pathname			// directory
	, compilerOptions	:: !CompilerOptions		// compiler options
110
	, mod_edit_options	:: !ModEditOptions
Diederik van Arkel's avatar
Diederik van Arkel committed
111 112 113
	, abcLinkInfo		:: !ABCLinkInfo
	}

114 115 116 117 118 119 120
::	ModEditOptions = {
		defeo 		:: !EditWdOptions,		// definition module edit options
		impeo		:: !EditWdOptions,		// implementation module edit options
		defopen 	:: !Bool,				// definition module is open
		impopen 	:: !Bool				// implementation module is open
	}

Diederik van Arkel's avatar
Diederik van Arkel committed
121 122 123 124 125 126 127 128 129 130 131 132
:: ABCLinkInfo = {linkObjFileNames :: !List LinkObjFileName, linkLibraryNames :: !List LinkLibraryName}

:: LinkObjFileName	:== String
:: LinkLibraryName	:== String

//-- Link Options

::	LinkOptions =
	{ extraObjectModules	:: !List {#Char}
	, libraries				:: !List {#Char}
	, method				:: !LinkMethod
	, generate_relocations	:: !Bool			// Win only option
133
	, generate_symbol_table	:: !Bool
Diederik van Arkel's avatar
Diederik van Arkel committed
134 135 136 137 138 139
	, generate_link_map		:: !Bool
	, link_resources		:: !Bool
	, resource_source		:: !String

	, generate_dll						:: !Bool
	, dll_export_list_name				:: !String
Diederik van Arkel's avatar
Diederik van Arkel committed
140
	
Diederik van Arkel's avatar
Diederik van Arkel committed
141
//	, add_carb_resource		:: !Bool			// Mac-only!
142 143

	, strip_bytecode		:: !Bool			// strip ABC bytecode
144
	, keep_bytecode_symbols	:: !Bool			// only meaningful when strip_bytecode=True
Diederik van Arkel's avatar
Diederik van Arkel committed
145
	}
Diederik van Arkel's avatar
Diederik van Arkel committed
146
/*
Diederik van Arkel's avatar
Diederik van Arkel committed
147 148 149 150 151 152 153 154 155 156 157
instance == LinkOptions		// do we need to check resource linking flags???
where
	(==) :: !LinkOptions !LinkOptions -> Bool
	(==) lo1 lo2 =

		lo1.method == lo2.method &&
		lo1.generate_relocations == lo2.generate_relocations &&
		lo1.generate_link_map == lo2.generate_link_map &&
		lo1.link_resources == lo2.link_resources &&
		(if lo1.link_resources (lo1.resource_source == lo2.resource_source) True) &&
		EQStrings (SortStrings lo1.extraObjectModules) (SortStrings lo2.extraObjectModules) &&
Diederik van Arkel's avatar
Diederik van Arkel committed
158 159 160
		EQStrings (SortStrings lo1.libraries) (SortStrings lo2.libraries) &&
		lo1.add_carb_resource == lo2.add_carb_resource
*/
Diederik van Arkel's avatar
Diederik van Arkel committed
161 162 163 164 165 166
DefaultLinkOptions :: LinkOptions;
DefaultLinkOptions =
	{ extraObjectModules		= Nil
	, libraries					= Nil
	, method					= LM_Static
	, generate_relocations		= False
167
	, generate_symbol_table		= False
Diederik van Arkel's avatar
Diederik van Arkel committed
168 169 170 171 172 173
	, generate_link_map			= False
	, link_resources			= False
	, resource_source			= ""

	, generate_dll						= False
	, dll_export_list_name				= ""
Diederik van Arkel's avatar
Diederik van Arkel committed
174
//	, add_carb_resource					= False	// Clean2 ide targets Carbon?!
175 176
	, strip_bytecode			= True
	, keep_bytecode_symbols		= True
Diederik van Arkel's avatar
Diederik van Arkel committed
177 178 179 180
	}

:: LinkMethod
	= LM_Static
Diederik van Arkel's avatar
Diederik van Arkel committed
181
//	| LM_Eager
Diederik van Arkel's avatar
Diederik van Arkel committed
182
	| LM_Dynamic
Diederik van Arkel's avatar
Diederik van Arkel committed
183 184
	| LM_StaticLibrary		// produce static library
	| LM_DynamicLibrary		// produce shared library
Diederik van Arkel's avatar
Diederik van Arkel committed
185 186 187 188

instance toString LinkMethod
where
	toString LM_Static	= "Static"
Diederik van Arkel's avatar
Diederik van Arkel committed
189
//	toString LM_Eager	= "Eager"
Diederik van Arkel's avatar
Diederik van Arkel committed
190
	toString LM_Dynamic	= "Dynamic"
Diederik van Arkel's avatar
Diederik van Arkel committed
191 192
	toString LM_StaticLibrary	= "StaticLibrary"
	toString LM_DynamicLibrary	= "DynamicLibrary"
Diederik van Arkel's avatar
Diederik van Arkel committed
193 194 195
	
instance fromString LinkMethod
where
Diederik van Arkel's avatar
Diederik van Arkel committed
196 197 198 199 200 201 202 203 204 205
	fromString "Static"			= LM_Static
	fromString "Eager"			= LM_Dynamic
	fromString "Dynamic"		= LM_Dynamic
	fromString "StaticLibrary"	= LM_StaticLibrary
	fromString "DynamicLibrary"	= LM_DynamicLibrary
/*
	fromString "Eager"			= LM_Eager
	fromString "Dynamic"		= LM_Dynamic
*/
	fromString _				= LM_Static
Diederik van Arkel's avatar
Diederik van Arkel committed
206 207 208 209

instance == LinkMethod
where
	(==) :: !LinkMethod !LinkMethod -> Bool
Diederik van Arkel's avatar
Diederik van Arkel committed
210 211 212 213 214 215
	(==) LM_Static			LM_Static			= True
//	(==) LM_Eager			LM_Eager			= True
	(==) LM_Dynamic			LM_Dynamic			= True
	(==) LM_StaticLibrary	LM_StaticLibrary	= True
	(==) LM_DynamicLibrary	LM_DynamicLibrary	= True
	(==) _					_					= False
Diederik van Arkel's avatar
Diederik van Arkel committed
216 217 218 219 220 221 222 223 224 225

//	Window position and size

::	WindowPos_and_Size	=
	{	posx	:: !Int
	,	posy	:: !Int
	,	sizex	:: !Int
	,	sizey	:: !Int
	}

226 227 228 229 230 231 232 233 234
instance == OptionalWindowPosAndSize
where
	(==) (WindowPosAndSize pos1) (WindowPosAndSize pos2)
		= pos1==pos2
	(==) NoWindowPosAndSize NoWindowPosAndSize
		= True
	(==) _ _
		= False

Diederik van Arkel's avatar
Diederik van Arkel committed
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
instance == WindowPos_and_Size
where
	(==) :: !WindowPos_and_Size !WindowPos_and_Size -> Bool
	(==) pos1 pos2
		=	pos1.posx == pos2.posx &&
			pos1.posy == pos2.posy &&
			pos1.sizex == pos2.sizex &&
			pos1.sizey == pos2.sizey

DefWindowPos_and_Size :: WindowPos_and_Size
DefWindowPos_and_Size =
	{ posx=0
	, posy=0
	, sizex=500
	, sizey=300
	}


//	The Editor Options: default settings for the EditWindows.

::	EditOptions	=
	{/*	tabs		:: !Int
	,	fontname	:: !String				// !FontName
	,	fontsize	:: !Int					// !FontSize
	,	autoi		:: !Bool
	,*/	newlines	:: !NewlineConvention
/*	,	showtabs	:: !Bool
	,	showlins	:: !Bool
	,	showsync	:: !Bool
*/	}
	// (tabs,font&size,auto indent)

instance == EditOptions
where
	(==) :: !EditOptions !EditOptions -> Bool
	(==) eo1 eo2
		= True
/*		=	eo1.tabs == eo2.tabs &&
			eo1.EditOptions.fontname == eo2.EditOptions.fontname &&
			eo1.EditOptions.fontsize == eo2.EditOptions.fontsize &&
			eo1.EditOptions.autoi == eo2.EditOptions.autoi
*/

//	The Window parameters: edit options and window position and size
::	EditWdOptions	=
	{	eo			:: !EditOptions
281
	,	pos_size	:: !OptionalWindowPosAndSize 
Diederik van Arkel's avatar
Diederik van Arkel committed
282 283 284 285
	}
	// edit options, window pos&size
	
//	The Code Generator Options: default settings for the code generator
Camil Staps's avatar
Camil Staps committed
286 287 288 289 290 291 292
::	CodeGenOptions	=
	{ cs				:: !Bool
	, ci				:: !Bool
//	, kaf				:: !Bool
//	, tp				:: !Processor
	, optimise_abc		:: !Bool
	, generate_bytecode	:: !Bool
Diederik van Arkel's avatar
Diederik van Arkel committed
293 294 295 296 297 298 299
	}

instance == CodeGenOptions
where
	(==) :: !CodeGenOptions !CodeGenOptions -> Bool
	(==) cg1 cg2
		=	cg1.cs == cg2.cs &&
300 301
			cg1.ci == cg2.ci &&
			cg1.generate_bytecode == cg2.generate_bytecode
Diederik van Arkel's avatar
Diederik van Arkel committed
302 303 304

DefCodeGenOptions :: CodeGenOptions;
DefCodeGenOptions =
Camil Staps's avatar
Camil Staps committed
305 306 307
	{	cs					= False
	,	ci					= True
	,	optimise_abc		= False
308
	,	generate_bytecode	= False
Diederik van Arkel's avatar
Diederik van Arkel committed
309 310 311 312 313 314 315 316 317 318 319 320 321
	}

//	The Application Options: default settings for the application.
::	ApplicationOptions	=
	{	hs								:: !Int
	,	ss								:: !Int
	,	em								:: !Int
	,	heap_size_multiple				:: !Int
	,	initial_heap_size				:: !Int
	,	set								:: !Bool
	,	sgc								:: !Bool
	,	pss								:: !Bool
	,	marking_collection				:: !Bool
322
	,	disable_rts_flags				:: !Bool
Diederik van Arkel's avatar
Diederik van Arkel committed
323 324 325 326 327 328 329 330
	,	o								:: !Output
	,	fn								:: !String		// !FontName
	,	fs								:: !Int			// !FontSize
	,	write_stderr_to_file			:: !Bool
	,	memoryProfiling 				:: !Bool
	,	memoryProfilingMinimumHeapSize	:: !Int
	,	profiling 						:: !Bool
	,	stack_traces					:: !Bool
331
	,	dynamics						:: !Bool
332 333
	,	generic_fusion					:: !Bool
	,	desc_exl						:: !Bool
Diederik van Arkel's avatar
Diederik van Arkel committed
334 335 336 337 338
	,	standard_rte					:: !Bool		// DvA: use standard RTE (only in IDE)
	}

DefApplicationOptions :: ApplicationOptions;
DefApplicationOptions =
339 340 341 342 343
	{	hs	= 2<<20
	,	ss	= 500<<10
	,	em	= 8<<10
	,	heap_size_multiple = 16<<8
	,	initial_heap_size = 200<<10
Diederik van Arkel's avatar
Diederik van Arkel committed
344 345 346 347
	,	set	= False
	,	sgc	= False
	,	pss	= False
	,	marking_collection = False
348
	,   disable_rts_flags = False
Diederik van Arkel's avatar
Diederik van Arkel committed
349
	,	o	= ShowConstructors
350
	,	fn	= "Monaco"				//=> platform dependant?
Diederik van Arkel's avatar
Diederik van Arkel committed
351 352 353 354 355 356 357
	,	fs	= 9						//=> platform dependant?
	,	write_stderr_to_file
						= False
	,	memoryProfiling = False
	,	memoryProfilingMinimumHeapSize = 0
	,	profiling = False
	,	stack_traces = False
358
	,	dynamics = False
359
	,	generic_fusion = False
360
	,	desc_exl = False
Diederik van Arkel's avatar
Diederik van Arkel committed
361 362 363
	,	standard_rte = True
	}
	
364
::	Output = BasicValuesOnly | ShowConstructors | NoReturnType | NoConsole
Diederik van Arkel's avatar
Diederik van Arkel committed
365 366 367

instance == Output
where
368
	(==) :: !Output !Output -> Bool
Diederik van Arkel's avatar
Diederik van Arkel committed
369 370 371 372
	(==) BasicValuesOnly BasicValuesOnly
		=	True
	(==) ShowConstructors ShowConstructors
		=	True
373 374
	(==) NoReturnType NoReturnType
		=	True
Diederik van Arkel's avatar
Diederik van Arkel committed
375 376 377 378 379 380 381
	(==) NoConsole NoConsole
		=	True
	(==) _ _
		=	False;

instance fromString Output
where
382
	fromString :: !{#Char} -> Output
Diederik van Arkel's avatar
Diederik van Arkel committed
383 384 385 386
	fromString "BasicValuesOnly"
		=	BasicValuesOnly
	fromString "ShowConstructors"
		=	ShowConstructors
387 388
	fromString "NoReturnType"
		=	NoReturnType
Diederik van Arkel's avatar
Diederik van Arkel committed
389 390 391 392 393 394 395
	fromString "NoConsole"
		=	NoConsole
	fromString string
		=	UnexpectedConstructor "Output" string BasicValuesOnly

instance toString Output
where
396
	toString :: !Output -> {#Char}
Diederik van Arkel's avatar
Diederik van Arkel committed
397 398 399 400
	toString BasicValuesOnly
		=	"BasicValuesOnly"
	toString ShowConstructors
		=	"ShowConstructors"
401 402
	toString NoReturnType
		=	"NoReturnType"
Diederik van Arkel's avatar
Diederik van Arkel committed
403 404 405 406 407 408 409 410 411 412 413 414 415
	toString NoConsole
		=	"NoConsole"

:: StaticLibInfo =
	{ sLibs :: !List Pathname
	, sDcls :: !List Modulename
	, sDeps :: !List Modulename
	}

isProjLibraryModule :: !.String !StaticLibInfo -> Bool
isProjLibraryModule mod info=:{sDcls}
	= StringOccurs mod sDcls