checksupport.dcl 6.02 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
11

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

cModuleScope	:== 0
cGlobalScope	:== 1

12
13
cIsNotADclModule 	:== False
cIsADclModule 		:== True
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
14

15
16
17
18
cNeedStdArray	:== 1
cNeedStdEnum	:== 2
cNeedStdDynamics:== 4

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

::	Heaps =
	{	hp_var_heap			::!.VarHeap
	,	hp_expression_heap	::!.ExpressionHeap
	,	hp_type_heaps		::!.TypeHeaps
	}

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

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

::	CheckStateX = {x_needed_modules :: !BITVECT,x_main_dcl_module_n :: !Int }
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

//	SymbolTable			:== {# SymbolTableEntry}

instance == STE_Kind

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

cTypeDefs				:== 0
cConstructorDefs		:== 1
cSelectorDefs			:== 2
cClassDefs				:== 3
cMemberDefs				:== 4
cInstanceDefs			:== 5
cFunctionDefs			:== 6
cMacroDefs				:== 7

cConversionTableSize	:== 8

::	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}
//	,	com_instance_types	:: !.{ SymbolType}
	}

60
61
::	Declarations = {
		dcls_import	::!{!Declaration}
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
62
	,	dcls_local		::![Declaration]
63
	,	dcls_local_for_import ::!{!Declaration}
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
64
65
	}

66
67
68
69
70
71
72
73
74
75
76
77
78
::	ExplImpInfos :== {!{!.ExplImpInfo}}

::	ExplImpInfo
		= ExplImpInfo Ident !.DeclaringModulesSet
		| TemporarilyFetchedAway

::	DeclaringModulesSet :== IntKeyHashtable DeclarationInfo

::	DeclarationInfo =
	{	di_decl			::	!Declaration
	,	di_instances	::	![Declaration]
	,	di_belonging	::	!NumberSet
	}
79

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
80
::	IclModule  =
81
82
83
84
85
	{	icl_name				:: !Ident
	,	icl_functions			:: !.{# FunDef }
	,	icl_instances			:: !IndexRange
	,	icl_specials			:: !IndexRange
	,	icl_common				:: !.CommonDefs
86
87
//	,	icl_declared		:: !Declarations
	,	icl_import		:: !{!Declaration}
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
88
	,	icl_imported_objects	:: ![ImportedObject]
89
	,	icl_used_module_numbers :: !NumberSet
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
90
91
92
93
94
95
96
97
98
99
	}

::	DclModule =
	{	dcl_name			:: !Ident
	,	dcl_functions		:: !{# FunType }
	,	dcl_instances		:: !IndexRange
	,	dcl_macros			:: !IndexRange
	,	dcl_class_specials	:: !IndexRange
	,	dcl_specials		:: !IndexRange
	,	dcl_common			:: !CommonDefs
100
	,	dcl_sizes			:: !{# Int}
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
101
102
103
	,	dcl_declared		:: !Declarations
	,	dcl_conversions		:: !Optional ConversionTable
	,	dcl_is_system		:: !Bool
104
	,	dcl_imported_module_numbers :: !NumberSet
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
105
106
107
108
109
110
111
112
113
114
	}

class Erroradmin state
where
	pushErrorAdmin :: !IdentPos *state -> *state
	setErrorAdmin :: !IdentPos *state -> *state
	popErrorAdmin  :: *state -> *state

instance Erroradmin ErrorAdmin, CheckState

115
newPosition :: !Ident !Position -> IdentPos 
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
116
117
118

checkError :: !a !b !*ErrorAdmin -> *ErrorAdmin | <<< a & <<< b
checkWarning :: !a !b !*ErrorAdmin -> *ErrorAdmin | <<< a & <<< b
Martin Wierich's avatar
Martin Wierich committed
119
checkErrorWithIdentPos :: !IdentPos !a !*ErrorAdmin -> .ErrorAdmin | <<< a;
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
120
121
122
123
124
125
126

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

instance envLookUp TypeVar, AttributeVar, ATypeVar

class toIdent a :: !a -> Ident

127
instance toIdent ConsDef, (TypeDef a), ClassDef, MemberDef, FunDef, SelectorDef // , ClassInstance
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
128
129
130
instance toIdent SymbIdent, TypeSymbIdent, BoundVar, TypeVar, ATypeVar, Ident

instance toInt STE_Kind
131
instance <<< IdentPos, ExplImpInfo, DeclarationInfo
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
132

133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
::	ExpressionInfo =
	{	ef_type_defs		:: !.{# CheckedTypeDef}
	,	ef_selector_defs	:: !.{# SelectorDef}
	,	ef_cons_defs		:: !.{# ConsDef}
	,	ef_member_defs		:: !.{# MemberDef}
	,	ef_class_defs		:: !.{# ClassDef}
	,	ef_modules			:: !.{# DclModule}
	,	ef_is_macro_fun		:: !Bool
	}

checkLocalFunctions :: !Index !Level !LocalDefs !*{#FunDef} !*ExpressionInfo !*Heaps !*CheckState
					-> (!.{#FunDef},!.ExpressionInfo,!.Heaps,!.CheckState);

convertIndex :: !Index !Index !(Optional ConversionTable) -> !Index

retrieveGlobalDefinition :: !SymbolTableEntry !STE_Kind !Index -> (!Index, !Index)
149
150
//retrieveAndRemoveImportsFromSymbolTable :: !Index  ![(.a,.Declarations)] !Int ![Declaration] !*ExplImpInfos !*(Heap SymbolTableEntry)
//		-> (!Int, ![Declaration], !.ExplImpInfos, !.Heap SymbolTableEntry);
151
addLocalFunctionDefsToSymbolTable :: !Level !Index !Index !Bool !*{#FunDef} !*SymbolTable !*ErrorAdmin -> (!*{# FunDef}, !*SymbolTable, !*ErrorAdmin)
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
152
addDefToSymbolTable :: !Level !Index !Ident !STE_Kind !*SymbolTable !*ErrorAdmin -> (!* SymbolTable, !*ErrorAdmin)
Martin Wierich's avatar
Martin Wierich committed
153
addDeclarationsOfDclModToSymbolTable :: .Int !{!Declaration} !{!Declaration} !*CheckState -> .CheckState;
154
addGlobalDefinitionsToSymbolTable :: ![Declaration] !*CheckState -> .CheckState;
Martin Wierich's avatar
Martin Wierich committed
155
156
addSymbol :: !(Optional a) !Ident !Position !STE_Kind !STE_Kind !.Int !.Int !Int !*CheckState -> (!Bool, !.CheckState)
addImportedFunctionOrMacro :: !(Optional IndexRange) !Ident !Int !*CheckState -> (!Bool, !.CheckState)
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
157
removeFieldFromSelectorDefinition :: !Ident .Int .Int !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry;
158
removeDeclarationsFromSymbolTable :: ![Declaration] !Int !*SymbolTable -> *SymbolTable
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
159
160
removeLocalIdentsFromSymbolTable :: .Int !.[Ident] !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry;
removeIdentFromSymbolTable :: !.Int !Ident !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry;
161
removeImportsAndLocalsOfModuleFromSymbolTable :: !Declarations !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry
162
163
164
165
removeLocalsFromSymbolTable :: !Level ![Ident] !LocalDefs !u:{# FunDef} !*(Heap SymbolTableEntry)
			-> (!u:{# FunDef}, !.Heap SymbolTableEntry)

newFreeVariable :: !FreeVar ![FreeVar] ->(!Bool, ![FreeVar])
166
167

local_declaration_for_import :: !u:Declaration .Index -> v:Declaration, [u <= v]
168
169
170
171
172
173
174
175
176
177

get_ident :: !ImportDeclaration -> Ident
getBelongingSymbolsFromID :: !ImportDeclaration -> Optional [ImportedIdent]

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

Martin Wierich's avatar
Martin Wierich committed
178
getBelongingSymbols :: !Declaration !v:{#DclModule} -> (!BelongingSymbols, !v:{#DclModule})
179
180
181
182
183
nrOfBelongingSymbols :: !BelongingSymbols -> Int

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

Martin Wierich's avatar
Martin Wierich committed
184
expand_syn_types_late_XXX yes no :== no