syntax.dcl 48.6 KB
Newer Older
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
1
2
3
4
5
definition module syntax

import StdEnv

import scanner, general, typeproperties, Heap
6
import IndexType
7
8
from containers import ::NumberSet

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
::	Ident =
	{ 	id_name		:: !String
	,	id_info 	:: !SymbolPtr
	}

instance toString Ident

/*	Each Identifier is equipped with a pointer to a SymbolTableEntry that is
	used for binding the identifier with its definition.
*/

::	SymbolTable			:== Heap SymbolTableEntry
::	SymbolPtr 			:== Ptr SymbolTableEntry

::	SymbolTableEntry = 
	{	ste_kind		:: !STE_Kind
	,	ste_index		:: !Index
	,	ste_def_level	:: !Level
	,	ste_previous	:: SymbolTableEntry
	}

30
31
32
33
34
:: FunctionOrMacroIndex
	= FunctionOrIclMacroIndex !Int
	| DclMacroIndex /*module_n*/ !Int /*macro_n_in_module*/ !Int
	| DeriveInstanceMacroIndex !Int
	| DeriveInstanceDclMacroIndex !Int !Int
35
36
37

instance == FunctionOrMacroIndex

38
::	STE_BoundTypeVariable	= { stv_attribute :: !TypeAttribute, stv_info_ptr :: !TypeVarInfoPtr }
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
39

40
41
::	STE_Kind	= STE_FunctionOrMacro ![FunctionOrMacroIndex]
				| STE_DclMacroOrLocalMacroFunction ![FunctionOrMacroIndex]
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
42
43
44
				| STE_Type
				| STE_Constructor
				| STE_Selector ![Global Index]
45
				| STE_Field !Ident // IC_Selector
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
46
47
				| STE_Class
				| STE_Member
48
				| STE_Generic !Int /* (#gen_vars<<1) + if arity<>0 1 0 */
49
				| STE_GenericCase
50
				| STE_GenericDeriveClass
51
				| STE_Instance
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
52
53
54
				| STE_Variable !VarInfoPtr
				| STE_TypeVariable !TypeVarInfoPtr
				| STE_BoundTypeVariable !STE_BoundTypeVariable
55
				| STE_Imported !STE_Kind !ModuleN
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
56
				| STE_DclFunction
57
				| STE_Module !(Module (CollectedDefinitions ClassInstance))
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
58
				| STE_ClosedModule
59
				| STE_ModuleQualifiedImports !SortedQualifiedImports
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
60
61
62
63
64
				| STE_Empty
					/* for creating class dictionaries */
				| STE_DictType !CheckedTypeDef
				| STE_DictCons !ConsDef
				| STE_DictField !SelectorDef
65
				| STE_Called ![FunctionOrMacroIndex] /* used during macro expansion to indicate that this function is called */
66
				| STE_ExplImpSymbol !Int
67
				| STE_ExplImpComponentNrs ![ComponentNrAndIndex]
68
					/*	stores the numbers of all module components that import the symbol from
69
						the "actual" dcl module.
70
71
					*/
				| STE_BelongingSymbol !Int
72
73
74
75
76
77
				| STE_ExplImpSymbolNotImported !ModuleN !STE_Kind
				| STE_ImportedQualified !Declaration !STE_Kind

				| STE_UsedType !ModuleN !STE_Kind
					/* used during binding of types to mark types that have been applied. */
				| STE_UsedQualifiedType !ModuleN !Index !STE_Kind
78
79
				| STE_BelongingSymbolExported
				| STE_BelongingSymbolForExportedSymbol
80
				| STE_TypeExtension
81
				| ..
82

83
84
85
86
::	ModuleN:==Int;

::	SortedQualifiedImports	= SortedQualifiedImports !Declaration !SortedQualifiedImports !SortedQualifiedImports
							| EmptySortedQualifiedImports
87

88
89
90
91
92
93
94
::	Declaration = Declaration !DeclarationRecord

::	DeclarationRecord =
	{	decl_ident	:: !Ident
	,	decl_pos	:: !Position
	,	decl_kind	:: !STE_Kind
	,	decl_index	:: !Index
95
96
97
98
99
100
101
	}

::	ComponentNrAndIndex =
	{	cai_component_nr	:: !Int
	,	cai_index			:: !Int // points into ExplImpInfos
	}

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
102
103
104
105
::	Global object =
	{	glob_object	:: !object
	,	glob_module	:: !Index
	}
106

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
107
::	Module defs = 
108
	{	mod_ident		:: !Ident
109
	,	mod_modification_time		:: {#Char}
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
110
111
112
	,	mod_type		:: !ModuleKind
	, 	mod_imports		:: ![ParsedImport]
	,	mod_imported_objects :: ![ImportedObject]
113
	,	mod_foreign_exports :: ![ParsedForeignExport]
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
114
115
116
	,	mod_defs		:: !defs
	}

117
118
119
120
121
122
123
::	ParsedForeignExport =
	{	pfe_ident	:: !Ident
	,	pfe_line	:: !Int
	,	pfe_file	:: !FileName
	,	pfe_stdcall	:: !Bool
	}

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
124
::	ParsedModule	:== Module  [ParsedDefinition]
125
::	ScannedModule 	:== Module  (CollectedDefinitions ScannedInstanceAndMembers)
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
126
	
127
::	ModuleKind		= MK_Main | MK_Module | MK_System | MK_None | MK_NoMainDcl
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
128

129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
::	FunDefIndex:==Int

::	IclFunctionIndices =
	{	ifi_global_function_indices	:: ![IndexRange]
	,	ifi_local_function_indices	:: !IndexRange
	,	ifi_instance_indices		:: ![IndexRange]
	,	ifi_specials_indices		:: !IndexRange
	,	ifi_gencase_indices			:: ![IndexRange]
	,	ifi_type_function_indices	:: ![IndexRange]
	}

::	IclModule  =
	{	icl_name				:: !Ident
	,	icl_functions			:: !.{# FunDef }
	,	icl_function_indices	:: !IclFunctionIndices
	,	icl_common				:: !.CommonDefs
145
	,	icl_imported_instances	:: ![!GlobalInstanceIndex!]
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
	,	icl_imported_objects	:: ![ImportedObject]
	,	icl_foreign_exports		:: ![ForeignExport]
	,	icl_used_module_numbers :: !NumberSet
	,	icl_modification_time	:: !{#Char}
	}

::	DclModule =
	{	dcl_name			:: !Ident
	,	dcl_functions		:: !{# FunType }
	,	dcl_instances		:: !IndexRange
	,	dcl_macros			:: !IndexRange
	,	dcl_specials		:: !IndexRange
	,	dcl_gencases		:: !IndexRange
	,	dcl_type_funs		:: !IndexRange
	,	dcl_common			:: !CommonDefs
	,	dcl_sizes			:: !{# Int}
	,	dcl_dictionary_info	:: !DictionaryInfo
	,	dcl_declared		:: !Declarations
164
	,	dcl_has_macro_conversions :: !Bool
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
	,	dcl_module_kind		:: !ModuleKind
	,	dcl_modification_time:: !{#Char}
	,	dcl_imported_module_numbers :: !NumberSet
	}

:: ForeignExport = {fe_fd_index :: !FunDefIndex, fe_stdcall :: !Bool}

::	CopiedDefinitions =
	{	copied_type_defs	:: {#Bool}
	,	copied_class_defs	:: {#Bool}
	,	copied_generic_defs :: {#Bool}
	}

::	Declarations = {
		dcls_import	::!{!Declaration}
	,	dcls_local		::![Declaration]
	,	dcls_local_for_import ::!{!Declaration}
	}

::	DictionaryInfo = { n_dictionary_types :: !Int, n_dictionary_constructors :: !Int, n_dictionary_selectors :: !Int }

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
186
::	RhsDefsOfType	= ConsList ![ParsedConstructor]
187
					| SelectorList !Ident ![ATypeVar] !Bool /*is_boxed_record*/ ![ParsedSelector]
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
188
					| TypeSpec !AType
John van Groningen's avatar
John van Groningen committed
189
					| NewTypeCons !ParsedConstructor
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
190
					| EmptyRhs !BITVECT
191
					| AbstractTypeSpec !BITVECT !AType
johnvg@science.ru.nl's avatar
johnvg@science.ru.nl committed
192
					| AbstractNewTypeCons !BITVECT !ParsedConstructor
193
					| ExtensibleConses ![ParsedConstructor]
194
					| MoreConses !Ident ![ParsedConstructor]
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
195

196
::	CollectedDefinitions instance_kind =
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
197
	{	def_types 			:: ![TypeDef TypeRhs]
198
199
	,	def_constructors	:: ![ConsDef]
	,	def_selectors		:: ![SelectorDef]
200
201
	,	def_macros			:: ![FunDef]
	,	def_macro_indices	:: !IndexRange
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
202
203
204
205
	,	def_classes			:: ![ClassDef]
	,	def_members			:: ![MemberDef]
	,	def_funtypes		:: ![FunType]
	,	def_instances		:: ![instance_kind]
206
207
208
209
	,	def_generics		:: ![GenericDef]
	, 	def_generic_cases 	:: ![GenericCaseDef]
	}

210
::	CommonDefs :== CommonDefsR DclInstanceMemberTypeAndFunctions
211
212

::	CommonDefsR member_types_and_functions =
213
214
215
216
217
	{	com_type_defs 		:: !.{# CheckedTypeDef}
	,	com_cons_defs		:: !.{# ConsDef}
	,	com_selector_defs	:: !.{# SelectorDef}
	,	com_class_defs		:: !.{# ClassDef}
	,	com_member_defs		:: !.{# MemberDef}
218
	,	com_instance_defs	:: !.{# ClassInstanceR member_types_and_functions}
219
220
	,	com_generic_defs	:: !.{# GenericDef}
	,	com_gencase_defs 	:: !.{# GenericCaseDef}
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
221
222
223
224
	}

::	LocalDefs	= LocalParsedDefs [ParsedDefinition]
				| CollectedLocalDefs CollectedLocalDefs
225
				| NoCollectedLocalDefs
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
226
227
228

::	IndexRange	= { ir_from :: !Index, ir_to :: !Index }

229
230
231
232
::	ArrayAndListInstances = {
		ali_array_first_instance_indices :: ![Int],
		ali_list_first_instance_indices :: ![Int],
		ali_tail_strict_list_first_instance_indices :: ![Int],
233
		ali_unboxed_maybe_first_instance_indices :: ![Int],
234
235
236
		ali_instances_range :: !IndexRange
	}

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
237
238
239
240
241
NoIndex		:== -1


::  Level	:== Int
NotALevel 	:==  -1
242
DictionaryLevel :== -2
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
243
244
245

::	CollectedLocalDefs =
	{	loc_functions	:: !IndexRange
246
	,	loc_nodes		:: ![NodeDef ParsedExpr]
247
	,	loc_in_icl_module :: !Bool // False for local functions in macros in dcl modules, otherwise True
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
248
249
250
251
252
	}

::	NodeDef dst =
	{	nd_dst		::!dst,
		nd_alts		::!OptGuardedAlts,
253
254
		nd_locals	::!LocalDefs,
		nd_position	::!Position		
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
255
256
257
258
259
260
261
262
263
264
265
266
	}

::	Rhs =
	{	rhs_alts	:: !OptGuardedAlts
	,	rhs_locals	:: !LocalDefs
	}


cIsAFunction	:== True
cIsNotAFunction :== False

::	ParsedDefinition 
267
268
	=	PD_Function Position Ident Bool [ParsedExpr] Rhs FunKind
	|	PD_NodeDef Position ParsedExpr Rhs
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
269
	|	PD_Type ParsedTypeDef
270
	|	PD_TypeSpec Position Ident Priority (Optional SymbolType) FunSpecials
271
	|	PD_LocalFunctionTypeSpec !Position !Ident !Priority ![!ATypeVarOrAttributeVar!] !SymbolType
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
272
	|	PD_Class ClassDef [ParsedDefinition]
273
274
	|	PD_Instance ParsedInstanceAndMembers
	|	PD_Instances [ParsedInstanceAndMembers]
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
275
276
	|	PD_Import [ParsedImport]
	|	PD_ImportedObjects [ImportedObject]
277
	|	PD_ForeignExport !Ident !{#Char} !Int !Bool /* if stdcall */
278
	|	PD_Generic GenericDef
279
	| 	PD_GenericCase GenericCaseDef Ident
280
	|	PD_Derive [GenericCaseDef]
281
	|	PD_DeriveInstanceMember Position Ident Ident !Int !(Optional Ident)
282
	|	PD_DeriveFunction !Position !Ident !TypeCons
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
283
284
	|	PD_Erroneous

285
::	FunKind = FK_Function !Bool | FK_Macro | FK_Caf | FK_NodeDefOrFunction | FK_Unknown
286
			| FK_FunctionWithDerive !Int !Int
287

288
289
::	ATypeVarOrAttributeVar = ATypeVar !ATypeVar | AttributeVar !AttributeVar | NoATypeVarOrAttributeVar

290
291
::	StrictnessList = NotStrict | Strict !Int | StrictList !Int StrictnessList

292
293
cNameNotLocationDependent :== False
cNameLocationDependent :== True
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
294
295

::	ParsedSelector =
296
297
	{	ps_field_ident		:: !Ident
	,	ps_selector_ident	:: !Ident
298
	,	ps_field_annotation	:: !Annotation
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
299
300
301
302
303
304
	,	ps_field_type		:: !AType
	,	ps_field_var		:: !Ident
	,	ps_field_pos		:: !Position
	}

::	ParsedConstructor =
305
	{	pc_cons_ident 	:: !Ident
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
306
307
308
	,	pc_cons_arity	:: !Int
	,	pc_exi_vars		:: ![ATypeVar]
	,	pc_arg_types	:: ![AType]
309
	,	pc_args_strictness	:: !StrictnessList
310
	,	pc_context		:: ![TypeContext]
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
311
312
313
	,	pc_cons_prio	:: !Priority
	,	pc_cons_pos		:: !Position
	}
314
315

::	ParsedInstance =
316
	{	pi_class 	:: !IdentOrQualifiedIdent
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
317
318
319
320
321
322
323
	,	pi_ident	:: !Ident
	,	pi_types	:: ![Type]
	,	pi_context	:: ![TypeContext]
	,	pi_pos		:: !Position
	,	pi_specials	:: !Specials
	}

324
325
326
327
328
::	ParsedInstanceAndMembers =
	{	pim_pi 		:: !ParsedInstance
	,	pim_members	:: ![ParsedDefinition]
	}

329
::	ScannedInstanceAndMembers =
330
	{	sim_pi 				:: !ParsedInstance
331
	,	sim_members			:: ![FunDef]	// for .icl
332
333
334
	,	sim_member_types	:: ![FunType]	// for .dcl
	}

335
336
337
::	DclInstanceMemberTypeAndFunctions
	= DclInstanceMemberTypes !FunType !DclInstanceMemberTypeAndFunctions
	| NoDclInstanceMemberTypes
338
	| GenerateInstanceMember !Int !Int !DclInstanceMemberTypeAndFunctions // member_n function_n
339
	| GenerateInstanceMemberFunction !Int !DclInstanceMemberTypeAndFunctions // member_n
340

341
342
343
344
::	IdentOrQualifiedIdent
	= Ident !Ident
	| QualifiedIdent /*module*/!Ident !String

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
345
346
347
348
349
/*
	Objects of type Specials are used to specify specialized instances of overloaded functions.
	These can only occur in definition modules. After parsing the SP_ParsedSubstitutions alternative
	is used to indicate the specific instantiation. The SP_Substitutions alternative is used to deduce
	the type of the specialized version. Finally the SP_ContextTypes alternative is set and used during 
350
	the typing to check whether this instance has been used. The auxiliary FSP_FunIndex alternative is used
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
351
352
353
354
355
356
357
	to store the index of the function that has been specialized.
*/

::	Specials
	= SP_ParsedSubstitutions 	![Env Type TypeVar]
	| SP_Substitutions 		 	![SpecialSubstitution]
	| SP_ContextTypes			![Special]
358
	| SP_TypeOffset				!Int					// index in SP_Substitutions for specialized instance
359
	| SP_GenerateRecordInstances	// for unboxed arrays and lists
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
360
361
	| SP_None

362
363
::	FunSpecials
	= FSP_ParsedSubstitutions 	![Env Type TypeVar]
364
	| FSP_Substitutions			![SpecialSubstitution]
365
366
	| FSP_ContextTypes			![Special]
	| FSP_FunIndex				!Index
367
	| FSP_ABCCode ![{#Char}]
368
369
	| FSP_None

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
::	SpecialSubstitution =
	{	ss_environ	:: !Env Type TypeVar
	,	ss_context	:: ![TypeContext]
	,	ss_vars		:: ![TypeVar]
	,	ss_attrs	:: ![AttributeVar]
	}

::	Special =
	{	spec_index	:: !Global Index
	,	spec_types	:: ![[Type]]
	,	spec_vars	:: ![TypeVar]
	, 	spec_attrs	:: ![AttributeVar]
	}

::	AttrInequality =
	{	ai_demanded :: !AttributeVar
	,	ai_offered	:: !AttributeVar
	}

::	DefinedSymbol = 
	{	ds_ident		:: !Ident
	,	ds_arity		:: !Int
	,	ds_index		:: !Index
	}

395
396
397
398
399
400
401
::	MacroIndex :== Int;

::	MacroMember = {
		mm_ident :: !Ident,
		mm_index :: !MacroIndex // only valid for class in dcl module
	}

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
402
::	ClassDef =
403
 	{	class_ident			:: !Ident
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
404
	,	class_arity			:: !Int
405
	,	class_args			:: !ClassArgs
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
406
407
	,	class_context		:: ![TypeContext]
	,	class_members		:: !{# DefinedSymbol}
408
	,	class_macro_members	:: {#MacroMember}
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
409
410
411
412
413
	,	class_dictionary	:: !DefinedSymbol
	,	class_pos			:: !Position
	,	class_cons_vars		:: !BITVECT
	}

414
415
::	ClassArgs
	= ClassArg !TypeVar !ClassArgs
416
	| ClassArgPattern !TypeVar ![ATypeVar] !ClassArgs
417
	| ClassArgPatternSameTypeVar ![ATypeVar] !ClassArgs
418
419
	| NoClassArgs

420
421
::	ClassDefInfos :== {# .{! [TypeKind]}}

422
423
424
425
::	MemberDefault
	= NoMemberDefault
	| MacroMemberDefault !MacroMember
	| DeriveDefault !Ident !GlobalIndex !(Optional IdentGlobalIndex)
426
	| MacroMemberDefaultWithDerive !MacroMember
427

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
428
::	MemberDef =
John van Groningen's avatar
John van Groningen committed
429
	{	me_ident		:: !Ident
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
430
431
432
433
	,	me_class		:: !Global Index
	,	me_offset		:: !Index
	,	me_type			:: !SymbolType
	,	me_type_ptr		:: !VarInfoPtr
434
	,	me_class_vars	:: !ClassArgs
435
	,	me_default_implementation :: !MemberDefault
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
436
437
438
439
	,	me_pos			:: !Position
	,	me_priority 	:: !Priority
	}

440
:: GenericDef = 
John van Groningen's avatar
John van Groningen committed
441
	{	gen_ident		:: !Ident		// the generics name in IC_Generic
442
	,	gen_member_ident	:: !Ident	// the generics name in IC_Expression
443
	, 	gen_pos			:: !Position
444
445
	,	gen_type		:: !SymbolType	// Generic type (st_vars include generic type vars)
	,	gen_vars		:: ![TypeVar]	// Generic type variables
446
	,	gen_deps		:: ![GenericDependency]	   // Generic function dependencies
447
	,	gen_info_ptr	:: !GenericInfoPtr
448
	}
Artem Alimarine's avatar
Artem Alimarine committed
449

450
451
452
453
454
455
456
457
458
:: GenericDependency =
	{	gd_ident		:: !IdentOrQualifiedIdent
	, 	gd_index		:: !GlobalIndex
	, 	gd_vars			:: ![TypeVar]
	,	gd_nums			:: ![Int] // Mapping from dependency variable to generic type variable
	}

instance == GenericDependency

459
460
461
462
463
464
465
466
467
468
469
:: GenericClassInfo = 
	{	gci_kind	:: !TypeKind	// the kind
	,	gci_module 	:: !Index		// filled with main_module_index
	,	gci_class	:: !Index		// class_index in the main module
	,	gci_member	:: !Index 		// the class member index 
	}
:: GenericClassInfos :== {[GenericClassInfo]}

:: GenericInfo = 
	{	gen_classes		:: !GenericClassInfos
	,	gen_var_kinds	:: ![TypeKind]  	// kinds of all st_vars of the gen_type
470
471
	,	gen_rep_conses	:: !{!GenericRepresentationConstructor}
	//	OBJECT, CONS, RECORD, FIELD, PAIR, EITHER, UNIT
472
	}
473

474
::	GenericRepresentationConstructor =
475
476
477
478
479
480
481
	{	grc_module	:: !Int
	,	grc_index	:: !GenericCaseBody // GCB_FunIndex, GCB_FunAndMacroIndex or GCB_None
	,	grc_local_fun_index :: !Int
	,	grc_ident	:: !Ident
	,	grc_generic_info :: !Int
	,	grc_generic_instance_deps :: !GenericInstanceDependencies
	,	grc_optional_fun_type :: !Optional SymbolType
482
483
	}

484
485
486
487
488
489
:: GenericInfoPtr :== Ptr GenericInfo	
:: GenericHeap :== Heap GenericInfo

:: TypeCons 
	= TypeConsSymb TypeSymbIdent 
	| TypeConsBasic BasicType 
490
	| TypeConsUnboxedArray TypeCons
491
	| TypeConsArrow
492
	| TypeConsVar TypeVar
493
494
	| TypeConsQualifiedIdent !Ident !String
	| ErroneousTypeCons
495

496
497
:: GenericCaseDef =
	{	gc_pos			:: !Position			// position in the source file
498
499
	,	gc_type			:: !Type				// the instance type
	,   gc_type_cons	:: !TypeCons			// type constructor of the type argument
500
	,	gc_gcf			:: !GenericCaseFunctions
501
	}
502
503
504

::	GenericCaseFunctions
	= GCF !Ident !GCF
505
506
	| GCFS ![!GCF!]
	| GCFC !Ident !Ident	// IC_GenericDeriveClass IC_Class
507
	| GCFCExcept !Ident !Ident ![!{#Char}!]	// IC_GenericDeriveClassExcept !Type ![!{#Char}!]
508
509

::	GCF = {
510
		gcf_gident	:: !Ident,	  			// name in IC_Generic namespace
511
512
		gcf_generic	:: !GlobalIndex,		// index of the generic
		gcf_arity	:: !Int,				// arity of the function
513
		gcf_generic_info :: !Int,			// 0 = no, -1 = all, generic info for CONS, OBJECT, RECORD or FIELD
514
		gcf_body	:: !GenericCaseBody,	// the body function or NoIndex
515
516
		gcf_kind	:: !TypeKind,			// kind of the instance type
		gcf_generic_instance_deps :: !GenericInstanceDependencies
517
518
	}

519
520
:: GenericCaseBody 
	= GCB_None 									// to be generated
521
	| GCB_FunIndex !Index
522
	| GCB_FunIndexAndIndices !Index ![Index]
523
524
525
	| GCB_FunAndMacroIndex !Index !Index
	| GCB_MacroIndex !Index
	| GCB_FunDef !FunDef
526
	| GCB_FunDefAndIndices !FunDef ![Index]
527
528
529
530
531
532
	| GCB_ParsedBody ![ParsedExpr] !Rhs

::	GenericInstanceDependencies
	= AllGenericInstanceDependencies
	| GenericInstanceDependencies !Int /*n_deps*/ !Int /*deps*/
	| GenericInstanceUsedArgs !Int /*n_deps*/ !Int /*deps*/
533

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
534
535
536
537
538
539
540
::	InstanceType =
	{	it_vars			:: [TypeVar]
	,	it_types		:: ![Type]
	,	it_attr_vars	:: [AttributeVar]
	,	it_context		:: ![TypeContext]
	}

541
::	ClassInstance :== ClassInstanceR DclInstanceMemberTypeAndFunctions
542
543

::	ClassInstanceR member_types_and_functions =
John van Groningen's avatar
John van Groningen committed
544
545
 	{	ins_class_index	:: !GlobalIndex
	,	ins_class_ident	:: !ClassIdent
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
546
547
	,	ins_ident		:: !Ident
	,	ins_type		:: !InstanceType
548
	,	ins_member_types_and_functions	:: !member_types_and_functions
549
	,	ins_members		:: !{#ClassInstanceMember}
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
550
551
552
553
	,	ins_specials	:: !Specials
	,	ins_pos			:: !Position
	}

John van Groningen's avatar
John van Groningen committed
554
::	ClassIdent =
555
	{	ci_ident		:: !IdentOrQualifiedIdent
John van Groningen's avatar
John van Groningen committed
556
557
558
	,	ci_arity		:: !Int
	}

559
560
561
562
563
564
::	ClassInstanceMember = 
	{	cim_ident		:: !Ident
	,	cim_arity		:: !Int		// module number if cim_index<0
	,	cim_index		:: !Index	// or -1-index
	}

565
::	Import =
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
566
	{	import_module		:: !Ident
567
	,	import_symbols		:: !ImportSymbols [ImportDeclaration]
Martin Wierich's avatar
Martin Wierich committed
568
	,	import_file_position:: !Position	// for error messages
569
	,	import_qualified	:: !ImportQualified
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
570
571
	}

572
573
574
575
::	ImportSymbols import_declarations
	= ImportSymbolsAll
	| ImportSymbolsOnly !import_declarations

576
577
::	ImportQualified = NotQualified | Qualified

578
instance toString Import, AttributeVar, TypeAttribute, Annotation
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
579

580
::	ParsedImport		:== Import
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
581

582
::	ImportDeclaration	= ID_Function !Ident
583
584
585
						| ID_Class !Ident !ImportBelongings
						| ID_Type !Ident !ImportBelongings
						| ID_Record !Ident !ImportBelongings
586
						| ID_Instance !Ident !Ident ![Type]
587
						| ID_Generic !Ident !Ident
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
588

589
590
::	ImportBelongings = IB_None | IB_Idents ![Ident] | IB_IdentsAndOptIdents ![Ident] ![Ident]

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
591
592
cIsImportedLibrary :== True
cIsImportedObject :== False
593

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
594
595
596
597
598
599
600
601
:: ImportedObject =
	{	io_is_library :: !Bool
	,	io_name    :: !{#Char}
	}

::	RecordType =
	{	rt_constructor	:: !DefinedSymbol
	,	rt_fields		:: !{# FieldSymbol}
602
	,	rt_is_boxed_record :: !Bool
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
603
	}
604

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
605
::	FieldSymbol =
606
607
	{	fs_ident		:: !Ident // IC_Field
	,	fs_var			:: !Ident // IC_Expression
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
608
609
610
611
612
613
	,	fs_index		:: !Index
	}

::	TypeRhs	= AlgType ![DefinedSymbol]
			| SynType !AType
			| RecordType !RecordType
John van Groningen's avatar
John van Groningen committed
614
			| NewType !DefinedSymbol
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
615
			| AbstractType !BITVECT
616
			| AbstractSynType !BITVECT !AType
johnvg@science.ru.nl's avatar
johnvg@science.ru.nl committed
617
			| AbstractNewType !BITVECT !DefinedSymbol
618
			| ExtensibleAlgType ![DefinedSymbol]
619
620
			| AlgConses ![DefinedSymbol] !GlobalIndex
			| UncheckedAlgConses !Ident ![DefinedSymbol]
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
621
622
623
624
625
626
627
628
			| UnknownType

::	ParsedTypeDef	:== TypeDef RhsDefsOfType
::	CheckedTypeDef	:== TypeDef TypeRhs

cAllBitsClear			:== 0
cIsHyperStrict			:== 1
cIsNonCoercible			:== 2
629
630
631
632
633
634
cIsAnalysed				:== 4

::	GlobalIndex =
	{	gi_module	::!Int
	,	gi_index	::!Int
	}
635
NoGlobalIndex :== {gi_module=NoIndex,gi_index=NoIndex}	
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
636

637
638
639
640
641
::	GlobalInstanceIndex =
	{	gii_module_n ::!Int
	,	gii_instance_n ::!Int
	}

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
642
::	TypeDef type_rhs =
643
	{	td_ident		:: !Ident
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
644
645
646
647
648
649
650
	,	td_index		:: !Int
	,	td_arity		:: !Int
	,	td_args			:: ![ATypeVar]
	,	td_attrs		:: ![AttributeVar]
	,	td_rhs			:: !type_rhs
	,	td_attribute	:: !TypeAttribute
	,	td_pos			:: !Position
651
	,	td_used_types	:: ![GlobalIndex]
652
	,	td_fun_index	:: !Index
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
653
654
655
656
657
	}

::	TypeDefInfo =
	{	tdi_kinds			:: ![TypeKind]
	,	tdi_properties		:: !BITVECT
658
	,	tdi_group			:: ![GlobalIndex]
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
659
660
661
	,	tdi_group_nr		:: !Int
	,	tdi_group_vars		:: ![Int]
	,	tdi_cons_vars		:: ![Int]
662
	,	tdi_index_in_group	:: !Index
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
663
	,	tdi_classification	:: !TypeClassification
664
	,	tdi_gen_rep 		:: !GenericTypeReps
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
665
666
	}

667
668
:: GenericTypeReps
	= NoGenericTypeReps
669
	| ..
670

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
671
672
673
::	TypeDefInfos :== {# .{# TypeDefInfo}}

::	FunType =
674
	{	ft_ident		:: !Ident
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
675
676
677
678
	,	ft_arity		:: !Int
	,	ft_priority		:: !Priority
	,	ft_type			:: !SymbolType
	,	ft_pos			:: !Position
679
	,	ft_specials		:: !FunSpecials
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
680
681
682
683
684
	,	ft_type_ptr		:: !VarInfoPtr
	}

::	FreeVar =
	{	fv_def_level	:: !Level
685
	,	fv_ident		:: !Ident
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
686
687
688
	,	fv_info_ptr		:: !VarInfoPtr
	,	fv_count		:: !Int
	}
689
690
691
692

::	ModuleIndex:==Index;
::	DclFunctionIndex:==Index;

693
694
695
696
::	FunCall	= FunCall !Index !Level
			| MacroCall !ModuleIndex !Index Level
			| DclFunCall !ModuleIndex !DclFunctionIndex
			| GeneratedFunCall !Index !FunctionInfoPtr;
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
697

698
699
FI_IsMacroFun	:== 1			// whether the function is a local function of a macro
FI_HasTypeSpec	:== 2			// whether the function has u user defined type
700
701
FI_IsNonRecursive :== 4			// used in trans.icl and partition.icl
FI_IsUnboxedListOfRecordsConsOrNil :== 8
702
FI_MemberInstanceRequiresTypeInDefMod :== 16
703
704
705
FI_GenericFun :== 32
FI_Unused :== 64				// used in module trans
FI_UnusedUsed :== 128			// used in module trans
706
FI_HasTypeCodes :== 256
707
FI_FusedMember :== 512			// used in module trans to mark fused versions of instance members
708
FI_DefaultMemberWithDerive :== 1024
709
FI_HasLocalGenerate :== 2048
710

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
711
712
713
::	FunInfo =
	{	fi_calls			:: ![FunCall]
	,	fi_group_index		:: !Index
714
	,	fi_def_level		:: !Level			// instance function index if FI_FusedMember set
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
715
716
717
	,	fi_free_vars		:: ![FreeVar]
	,	fi_local_vars		:: ![FreeVar]
	,	fi_dynamics			:: ![ExprInfoPtr]
718
	,	fi_properties		:: !BITVECT
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
719
720
721
	}

::	ParsedBody =
722
723
724
	{	pb_args		:: ![ParsedExpr]
	,	pb_rhs		:: !Rhs
	,	pb_position	:: !Position
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
725
726
727
	}

::	CheckedBody =
728
729
	{	cb_args		:: ![FreeVar]
	,	cb_rhs		:: ![CheckedAlternative]
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
730
731
	}

732
733
734
735
736
737
::	CheckedAlternative =
	{	ca_rhs		:: !Expression
	,	ca_position	:: !Position	// the position is NoPos iff the position information for this
	}								// alternative is already stored in a case alternative
									// (in ap_position, bp_position or dp_position)

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
738
739
740
741
742
743
744
745
::	TransformedBody =
	{	tb_args			:: ![FreeVar]
	,	tb_rhs			:: !Expression
	}

::	FunctionBody	= ParsedBody ![ParsedBody]
					| CheckedBody !CheckedBody
	/* The next three constructors are used during macro expansion (module transform) */
746
747
					| PartitioningMacro
					| PartitioningFunction !CheckedBody !Int
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
748
749
750
					| RhsMacroBody !CheckedBody
	/* macro expansion transforms a CheckedBody into a TransformedBody */
					| TransformedBody !TransformedBody
751
					| Expanding ![FreeVar] // the parameters of the newly generated function
752
					| GeneratedBody // the body will be generated automatically - for generics
753
					| GenerateInstanceBody !Ident !(Optional Ident)
754
					| GenerateGenericBody !TypeCons
755
					| GenerateInstanceBodyChecked !Ident !GlobalIndex !(Optional IdentGlobalIndex)
756
757
					| GenerateInstanceBodyLocalMacro !Ident !GlobalIndex !(Optional IdentGlobalIndex)
					| PartitioningGenerateInstanceBodyLocalMacro !Ident !GlobalIndex !(Optional IdentGlobalIndex) !Int 
758
					| NoBody
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
759

760
761
:: IdentGlobalIndex = { igi_ident :: !Ident, igi_g_index :: !GlobalIndex }

762
763
:: FunDefType	= FunDefType !SymbolType
				| NoFunDefType
764
765
				| LocalFunDefType ![!ATypeVarOrAttributeVar!] !SymbolType
				| LocalFunDefCheckedType ![!TypeVar!] ![!AttributeVar!] !SymbolType
766

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
767
::	FunDef =
768
	{	fun_ident		:: !Ident
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
769
770
771
	,	fun_arity		:: !Int
	,	fun_priority	:: !Priority
	,	fun_body		:: !FunctionBody
772
	,	fun_type		:: !FunDefType
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
773
	,	fun_pos			:: !Position
774
	,	fun_kind		:: !FunKind
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
775
776
777
778
779
780
781
782
	,	fun_lifted		:: !Int
	,	fun_info		:: !FunInfo
	}

cIsAGlobalVar	:== True
cIsALocalVar	:== False

::	ConsClasses =
783
	{	cc_size			::!Int
784
	,	cc_args			::![ConsClass]
785
	,	cc_linear_bits	::![#Bool!]
786
	,	cc_producer		::!ProdClass
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
787
	}
788

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
789
790
::	ConsClass	:== Int

791
792
793
794
::	ProdClass	:== Bool

pIsSafe			:== True

795
796
797
798
::	ImportedConstructors	:== [Global Index]
::	ImportedFunctions		:== [Global Index]
::	ImportedTypes			:== {#{# CheckedTypeDef}}

799
::	VI_TypeInfo	= VITI_Empty
800
				| ..
801

802
803
::	VarInfo  =	VI_Empty | VI_Type !AType !VI_TypeInfo |
				VI_FAType ![ATypeVar] !AType !VI_TypeInfo |
804
				VI_FATypeC ![ATypeVar] !AType ![TypeContext] !VI_TypeInfo | VI_FPC |
805
				VI_Expression !Expression | VI_Variable !Ident !VarInfoPtr |
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
806
				VI_Count !Int /* the reference count of a variable */ !Bool /* true if the variable is global, false otherwise */ |
807
				VI_AccVar !ConsClass !ArgumentPosition /* used during fusion to determine accumulating parameters of functions */ |
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
808
809
				VI_Alias !BoundVar /* used for resolving aliases just before type checking (in transform) */ |
				 /* used during elimination and lifting of cases */
810
				VI_LocalVar |
Sjaak Smetsers's avatar
Sjaak Smetsers committed
811
				VI_ClassVar !Ident !VarInfoPtr !Int | /* to hold dictionary variables during overloading */
812
				VI_EmptyConstructorClassVar |
Sjaak Smetsers's avatar
Sjaak Smetsers committed
813
				VI_ForwardClassVar !VarInfoPtr | /* to hold the dictionary variable generated during overloading */
814
815
				VI_ForwardClassVars !VarInfoPtr !VarInfo |
				VI_ForwardTypeContextVar !VarInfoPtr |
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
816
817
818
				VI_Used | /* for indicating that an imported function has been used */
				VI_PropagationType !SymbolType | /* for storing the type with propagation environment of an imported function */
				VI_ExpandedType !SymbolType | /* for storing the (expanded) type of an imported function */
819
				VI_ExpandedMemberType !SymbolType !VarInfo /* VI_Empty or VI_ExpandedType */ | // only in sd_type_ptr
Sjaak Smetsers's avatar
Sjaak Smetsers committed
820
				VI_Extended !ExtendedVarInfo !VarInfo |
821
				..
822

823
::	ExtendedVarInfo = EVI_VarType !AType
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
824

825
826
::	ArgumentPosition :== Int

827
::	VarHeap :== Heap VarInfo
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
828
829
830
831
832
::	VarInfoPtr	:== Ptr VarInfo

cNotVarNumber :== -1

::	BoundVar = 
833
	{	var_ident		:: !Ident
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
834
835
836
837
838
	,	var_info_ptr	:: !VarInfoPtr
	,	var_expr_ptr	:: !ExprInfoPtr
	}

::	TypeSymbIdent =
839
	{	type_ident		:: !Ident
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
840
841
842
843
844
845
846
847
848
849
850
851
852
	,	type_arity		:: !Int
	,	type_index		:: !Global Index
	,	type_prop		:: !TypeSymbProperties
	}

::	TypeSymbProperties =
	{	tsp_sign		:: !SignClassification
	,	tsp_propagation	:: !PropClassification
	,	tsp_coercible	:: !Bool
	}

::	SymbKind	= SK_Unknown
				| SK_Function !(Global Index)
853
				| SK_IclMacro !Index
854
				| SK_LocalMacroFunction !Index
855
856
				| SK_DclMacro !(Global Index)
				| SK_LocalDclMacroFunction !(Global Index)
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
857
858
				| SK_OverloadedFunction !(Global Index)
				| SK_GeneratedFunction !FunctionInfoPtr !Index
859
				| SK_Constructor !(Global Index)
John van Groningen's avatar
John van Groningen committed
860
				| SK_NewTypeConstructor !GlobalIndex
861
				| SK_Generic !(Global Index) !TypeKind
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
862
				| SK_TypeCode
863
864
865
866
				| SK_OverloadedConstructor !(Global Index)
				| SK_TFACVar !ExprInfoPtr
				| SK_VarContexts !(VarContexts TypeContext)
				| SK_TypeCodeAndContexts !(VarContexts TypeContext)
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
867
868
869
870
871
872
873
874
875
876
877
878
879

/*	Some auxiliary type definitions used during fusion. Actually, these definitions
	should have been given in seperate module. Unfortunately, Clean's module system
	forbids cyclic dependencies between def modules.
*/

::	FunctionHeap 	:== Heap FunctionInfo

::	FunctionInfoPtr	:== Ptr FunctionInfo

::	FunctionInfo	= FI_Empty | FI_Function !GeneratedFunction

::	Producer	= PR_Empty
880
				| PR_Function !SymbIdent !Int !Index
Martin Wierich's avatar
Martin Wierich committed
881
				| PR_Class !App ![(BoundVar, Type)] !Type
882
883
884
				| PR_Constructor !SymbIdent !Int ![Expression]
				| PR_GeneratedFunction !SymbIdent !Int !Index
				| PR_Curried !SymbIdent !Int
885
				| PR_Unused
886
				| PR_CurriedFunction !SymbIdent !Int !Index
887
888
				| PR_String !{#Char}
				| PR_Int !Int
889
				| PR_Equal
890
				| PR_EqualRemove !Int
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915

::	InstanceInfo = II_Empty | II_Node !{! Producer} !FunctionInfoPtr !InstanceInfo !InstanceInfo

::	GeneratedFunction = 
	{	gf_fun_def			:: !FunDef
	,	gf_instance_info	:: !InstanceInfo
	,	gf_cons_args		:: !ConsClasses
	,	gf_fun_index		:: !Index
	}
	
/*	... main type definitions continued .... */

::	ExpressionHeap 	:== Heap ExprInfo

::	ExprInfoPtr		:== Ptr ExprInfo

::	TempLocalVar	:== Int

::	DynamicPtr		:== ExprInfoPtr

::	ExprInfo		= EI_Empty

		/* For handling overloading */

					| EI_Overloaded !OverloadedCall 						/* initial, set by the type checker */
916
					| EI_OverloadedWithVarContexts !OverloadedCallWithVarContexts /* initial, set by the type checker */
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
917
					| EI_Instance 	!(Global DefinedSymbol) ![Expression]	/* intermedediate, used during resolving of overloading */ 
Sjaak Smetsers's avatar
Sjaak Smetsers committed
918
					| EI_Selection 	![Selection] !VarInfoPtr ![Expression]	/* intermedediate, used during resolving of overloading */
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
919
					| EI_Context 	![Expression]							/* intermedediate, used during resolving of overloading */
920
921
					| EI_ContextWithVarContexts ![Expression] !(VarContexts DictionaryAndClassType) /* intermedediate, used during resolving of overloading */
					| EI_FPContext	![Expression] !ExprInfoPtr				/* intermedediate, used during resolving of overloading */
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
922
923
924

		/* For handling dynamics */

925
926
927
					| EI_UnmarkedDynamic 		!(Optional DynamicType) ![DynamicPtr]	// in expression
					| EI_Dynamic 				!(Optional DynamicType) ![DynamicPtr]	// in expression
					| EI_DynamicType			!DynamicType ![DynamicPtr]				// in pattern
928
					| EI_DynamicCopy !ExprInfoPtr !ExprInfo // used in module transform to copy dynamics in macros
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
929
930
931
932
933
934
935

		/* Auxiliary, was EI_DynamicType before checking */

					| EI_DynamicTypeWithVars	![TypeVar] !DynamicType ![DynamicPtr]				

		/* Auxiliary, used during type checking */

936
					| EI_TempDynamicType 		!(Optional DynamicType) ![DynamicPtr] !AType ![TypeContext] ![TypeContext] !ExprInfoPtr !SymbIdent
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
937
					| EI_TempDynamicPattern 	![TypeVar] !DynamicType ![DynamicPtr] ![TempLocalVar] !AType ![TypeContext] !ExprInfoPtr !SymbIdent
938
939

					| EI_TypeOfDynamic 			!TypeCodeExpression						/* Final */
940
					| EI_TypeOfDynamicAndTCsToFind !TypeCodeExpression !Ident ![VarInfoPtr]
941
					| EI_TypeOfDynamicPattern 	![VarInfoPtr] !TypeCodeExpression !Bool	/* Final */
942
					| EI_TypeOfDynamicWithContexts !TypeCodeExpression !(VarContexts DictionaryAndClassType)
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
943
944
945

					| EI_TypeCode 		!TypeCodeExpression
					| EI_TypeCodes 		![TypeCodeExpression]
946
					| EI_TypeCodesWithContexts ![TypeCodeExpression] !(VarContexts DictionaryAndClassType)
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
947
948
949

					| EI_Attribute !Int

950
		/* EI_DictionaryType is used to store the instance type of a class. This type is used during fusion to generate proper types for 
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
951
952
		   the fusion result (i.e. the resulting function after elimination of dictionaries) */

953
					| EI_DictionaryType !Type
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
954
955
					| EI_CaseType !CaseType
					| EI_LetType ![AType]
956
					| EI_CaseTypeWithContexts !CaseType ![(DefinedSymbol,[TypeContext])]
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
957
958
959
960
					| EI_LetTypeAndRefCounts ![AType] ![Int]

		/* for converting case into function patterns the following auxiliary constuctors are used */

961
					| EI_Extended !ExtendedExprInfo !ExprInfo
962
					| ..
Martin Wierich's avatar