checksupport.dcl 7.05 KB
Newer Older
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
1
2
3
definition module checksupport

import StdEnv
4
import syntax, predef, containers, utilities
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
5
6
7
8
9
10

CS_NotChecked 	:== -1
NotFound		:== -1

cModuleScope	:== 0
cGlobalScope	:== 1
11
cRankTwoScope	:== 2
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
12

13
14
cNeedStdArray	:== 1
cNeedStdEnum	:== 2
15
cNeedStdDynamic :== 4
16
cNeedStdGeneric	:== 8
17
cNeedStdStrictLists :== 16
18

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
19
20
21
22
23
24
::	VarHeap :== Heap VarInfo

::	Heaps =
	{	hp_var_heap			::!.VarHeap
	,	hp_expression_heap	::!.ExpressionHeap
	,	hp_type_heaps		::!.TypeHeaps
25
	,	hp_generic_heap		::!.GenericHeap
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
26
27
28
29
	}

::	ErrorAdmin = { ea_file :: !.File, ea_loc :: ![IdentPos], ea_ok :: !Bool }

30
31
::	CheckState = { cs_symbol_table :: !.SymbolTable, cs_predef_symbols :: !.PredefinedSymbols, cs_error :: !.ErrorAdmin,cs_x :: !CheckStateX }

32
::	CheckStateX = {x_needed_modules :: !BITVECT,x_main_dcl_module_n :: !Int, x_check_dynamic_types :: !Bool }
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
33
34
35
36
37
38
39
40
41
42
43
44

//	SymbolTable			:== {# SymbolTableEntry}

instance == STE_Kind

::	ConversionTable		:== {# .{# Int }}

cTypeDefs				:== 0
cConstructorDefs		:== 1
cSelectorDefs			:== 2
cClassDefs				:== 3
cMemberDefs				:== 4
45
cGenericDefs			:== 5
46
47
48
49
cGenericCaseDefs		:== 6
cInstanceDefs			:== 7
cFunctionDefs			:== 8
cMacroDefs				:== 9
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
50

51
cConversionTableSize	:== 10
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
52
53
54
55
56
57
58
59

::	CommonDefs =
	{	com_type_defs 		:: !.{# CheckedTypeDef}
	,	com_cons_defs		:: !.{# ConsDef}
	,	com_selector_defs	:: !.{# SelectorDef}
	,	com_class_defs		:: !.{# ClassDef}
	,	com_member_defs		:: !.{# MemberDef}
	,	com_instance_defs	:: !.{# ClassInstance}
60
61
	,	com_generic_defs	:: !.{# GenericDef}
	,	com_gencase_defs 	:: !.{# GenericCaseDef}
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
62
63
	}

64
65
::	Declarations = {
		dcls_import	::!{!Declaration}
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
66
	,	dcls_local		::![Declaration]
67
	,	dcls_local_for_import ::!{!Declaration}
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
68
69
	}

70
::	*ExplImpInfos :== *{!*{!*ExplImpInfo}}
71
72
73
74
75
76
77
78
79
80
81

::	ExplImpInfo
		= ExplImpInfo Ident !.DeclaringModulesSet
		| TemporarilyFetchedAway

::	DeclaringModulesSet :== IntKeyHashtable DeclarationInfo

::	DeclarationInfo =
	{	di_decl			::	!Declaration
	,	di_belonging	::	!NumberSet
	}
82

83
::	CopiedDefinitions =
84
85
	{	copied_type_defs	:: {#Bool}
	,	copied_class_defs	:: {#Bool}
86
	,	copied_generic_defs :: {#Bool}
87
88
	}
	
John van Groningen's avatar
John van Groningen committed
89
90
::	FunDefIndex:==Int

91
92
93
94
95
96
97
98
99
::	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]
	}

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
100
::	IclModule  =
101
102
	{	icl_name				:: !Ident
	,	icl_functions			:: !.{# FunDef }
103
	,	icl_function_indices	:: !IclFunctionIndices
104
	,	icl_common				:: !.CommonDefs
105
	,	icl_import				:: !{!Declaration}
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
106
	,	icl_imported_objects	:: ![ImportedObject]
107
	,	icl_foreign_exports		:: ![ForeignExport]
108
	,	icl_used_module_numbers :: !NumberSet
109
	,	icl_copied_from_dcl 	:: !CopiedDefinitions
110
	,	icl_modification_time	:: !{#Char}
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
111
112
	}

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

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
115
116
117
118
119
120
::	DclModule =
	{	dcl_name			:: !Ident
	,	dcl_functions		:: !{# FunType }
	,	dcl_instances		:: !IndexRange
	,	dcl_macros			:: !IndexRange
	,	dcl_specials		:: !IndexRange
121
	,	dcl_gencases		:: !IndexRange
122
	,	dcl_type_funs		:: !IndexRange
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
123
	,	dcl_common			:: !CommonDefs
124
	,	dcl_sizes			:: !{# Int}
125
	,	dcl_dictionary_info	:: !DictionaryInfo
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
126
	,	dcl_declared		:: !Declarations
127
	,	dcl_macro_conversions :: !Optional {#Index}
128
	,	dcl_module_kind		:: !ModuleKind
129
	,	dcl_modification_time:: !{#Char}
130
	,	dcl_imported_module_numbers :: !NumberSet
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
131
132
	}

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

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
135
136
137
138
139
140
141
142
class Erroradmin state
where
	pushErrorAdmin :: !IdentPos *state -> *state
	setErrorAdmin :: !IdentPos *state -> *state
	popErrorAdmin  :: *state -> *state

instance Erroradmin ErrorAdmin, CheckState

143
newPosition :: !Ident !Position -> IdentPos 
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
144
145
146

checkError :: !a !b !*ErrorAdmin -> *ErrorAdmin | <<< a & <<< b
checkWarning :: !a !b !*ErrorAdmin -> *ErrorAdmin | <<< a & <<< b
Martin Wierich's avatar
Martin Wierich committed
147
checkErrorWithIdentPos :: !IdentPos !a !*ErrorAdmin -> .ErrorAdmin | <<< a;
148
checkErrorWithPosition :: !Ident !Position !a !*ErrorAdmin -> .ErrorAdmin | <<< a;
149
checkWarningWithPosition :: !Ident !Position !a !*ErrorAdmin -> .ErrorAdmin | <<< a;
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
150
151
152
153
154
155
156

class envLookUp a :: !a !(Env Ident .b) -> (!Bool,.b)

instance envLookUp TypeVar, AttributeVar, ATypeVar

class toIdent a :: !a -> Ident

157
instance toIdent ConsDef, (TypeDef a), ClassDef, MemberDef, FunDef, SelectorDef // , ClassInstance
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
158
159
160
instance toIdent SymbIdent, TypeSymbIdent, BoundVar, TypeVar, ATypeVar, Ident

instance toInt STE_Kind
161
instance <<< IdentPos, ExplImpInfo, DeclarationInfo
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
162

163
164
165
166
167
168
::	ExpressionInfo =
	{	ef_type_defs		:: !.{# CheckedTypeDef}
	,	ef_selector_defs	:: !.{# SelectorDef}
	,	ef_cons_defs		:: !.{# ConsDef}
	,	ef_member_defs		:: !.{# MemberDef}
	,	ef_class_defs		:: !.{# ClassDef}
169
	,	ef_generic_defs		:: !.{# GenericDef}
170
	,	ef_modules			:: !.{# DclModule}
171
	,	ef_macro_defs		:: !.{#.{#FunDef}}
172
173
174
	,	ef_is_macro_fun		:: !Bool
	}

175
//convertIndex :: !Index !Index !(Optional ConversionTable) -> !Index
176
177

retrieveGlobalDefinition :: !SymbolTableEntry !STE_Kind !Index -> (!Index, !Index)
178

179
addLocalFunctionDefsToSymbolTable :: !Level !Index !Index !Bool !*{#FunDef} !*SymbolTable !*ErrorAdmin -> (!*{# FunDef}, !*SymbolTable, !*ErrorAdmin)
180
addLocalDclMacroDefsToSymbolTable :: !Level !Int !Index !Index !*{#*{#FunDef}} !*SymbolTable !*ErrorAdmin -> (!*{#*{#FunDef}}, !*SymbolTable, !*ErrorAdmin)
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
181
addDefToSymbolTable :: !Level !Index !Ident !STE_Kind !*SymbolTable !*ErrorAdmin -> (!* SymbolTable, !*ErrorAdmin)
Martin Wierich's avatar
Martin Wierich committed
182
addDeclarationsOfDclModToSymbolTable :: .Int !{!Declaration} !{!Declaration} !*CheckState -> .CheckState;
183
addGlobalDefinitionsToSymbolTable :: ![Declaration] !*CheckState -> .CheckState;
Martin Wierich's avatar
Martin Wierich committed
184
185
addSymbol :: !(Optional a) !Ident !Position !STE_Kind !STE_Kind !.Int !.Int !Int !*CheckState -> (!Bool, !.CheckState)
addImportedFunctionOrMacro :: !(Optional IndexRange) !Ident !Int !*CheckState -> (!Bool, !.CheckState)
186

187
removeImportedSymbolsFromSymbolTable :: Declaration !*SymbolTable -> .SymbolTable
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
188
removeFieldFromSelectorDefinition :: !Ident .Int .Int !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry;
189
removeDeclarationsFromSymbolTable :: ![Declaration] !Int !*SymbolTable -> *SymbolTable
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
190
191
removeLocalIdentsFromSymbolTable :: .Int !.[Ident] !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry;
removeIdentFromSymbolTable :: !.Int !Ident !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry;
192
removeImportsAndLocalsOfModuleFromSymbolTable :: !Declarations !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry
193
194
removeLocalFunctionsFromSymbolTable :: !Level !IndexRange !*{# FunDef} !*(Heap SymbolTableEntry) -> (!.{# FunDef}, !.Heap SymbolTableEntry)
removeLocalDclMacrosFromSymbolTable :: !Level !Index !IndexRange !*{#*{#FunDef}} !*(Heap SymbolTableEntry) -> (!.{#.{#FunDef}}, !.Heap SymbolTableEntry)
195
196

newFreeVariable :: !FreeVar ![FreeVar] ->(!Bool, ![FreeVar])
197
198

local_declaration_for_import :: !u:Declaration .Index -> v:Declaration, [u <= v]
199
200
201
202
203
204
205

:: BelongingSymbols
	=	BS_Constructors ![DefinedSymbol]
	|	BS_Fields !{#FieldSymbol}
	|	BS_Members !{#DefinedSymbol}
	|	BS_Nothing

Martin Wierich's avatar
Martin Wierich committed
206
getBelongingSymbols :: !Declaration !v:{#DclModule} -> (!BelongingSymbols, !v:{#DclModule})
207
208
209
210
nrOfBelongingSymbols :: !BelongingSymbols -> Int

import_ident :: Ident
restoreHeap :: !Ident !*SymbolTable -> .SymbolTable