checksupport.dcl 4.87 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
15
16
17
cStdArrayImportMissing	:== 1
cStdEnumImportMissing	:== 2
cNeedStdDynamic 		:== 4
cNeedStdGeneric			:== 8
cNeedStdStrictLists		:== 16
18

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
19
20
21
22
::	Heaps =
	{	hp_var_heap			::!.VarHeap
	,	hp_expression_heap	::!.ExpressionHeap
	,	hp_type_heaps		::!.TypeHeaps
23
	,	hp_generic_heap		::!.GenericHeap
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
24
25
26
27
	}

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

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

30
::	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
31
32
33
34
35
36
37
38

instance == STE_Kind

cTypeDefs				:== 0
cConstructorDefs		:== 1
cSelectorDefs			:== 2
cClassDefs				:== 3
cMemberDefs				:== 4
39
cGenericDefs			:== 5
40
41
42
43
cGenericCaseDefs		:== 6
cInstanceDefs			:== 7
cFunctionDefs			:== 8
cMacroDefs				:== 9
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
44

45
cConversionTableSize	:== 10
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
46

47
::	*ExplImpInfos :== *{#*{!*ExplImpInfo}}
48
49
50
51
52
53
54
55
56
57

::	ExplImpInfo
		= ExplImpInfo Ident !.DeclaringModulesSet

::	DeclaringModulesSet :== IntKeyHashtable DeclarationInfo

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

Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
59
60
61
62
63
64
65
66
class Erroradmin state
where
	pushErrorAdmin :: !IdentPos *state -> *state
	setErrorAdmin :: !IdentPos *state -> *state
	popErrorAdmin  :: *state -> *state

instance Erroradmin ErrorAdmin, CheckState

67
newPosition :: !Ident !Position -> IdentPos 
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
68
69
70

checkError :: !a !b !*ErrorAdmin -> *ErrorAdmin | <<< a & <<< b
checkWarning :: !a !b !*ErrorAdmin -> *ErrorAdmin | <<< a & <<< b
Martin Wierich's avatar
Martin Wierich committed
71
checkErrorWithIdentPos :: !IdentPos !a !*ErrorAdmin -> .ErrorAdmin | <<< a;
72
checkErrorWithPosition :: !Ident !Position !a !*ErrorAdmin -> .ErrorAdmin | <<< a;
73
checkWarningWithPosition :: !Ident !Position !a !*ErrorAdmin -> .ErrorAdmin | <<< a;
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
74
75
76
77
78
79
80

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

instance envLookUp TypeVar, AttributeVar, ATypeVar

class toIdent a :: !a -> Ident

81
instance toIdent ConsDef, (TypeDef a), ClassDef, MemberDef, FunDef, SelectorDef // , ClassInstance
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
82
83
84
instance toIdent SymbIdent, TypeSymbIdent, BoundVar, TypeVar, ATypeVar, Ident

instance toInt STE_Kind
85
instance <<< IdentPos, ExplImpInfo, DeclarationInfo
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
86

87
88
89
90
91
92
::	ExpressionInfo =
	{	ef_type_defs		:: !.{# CheckedTypeDef}
	,	ef_selector_defs	:: !.{# SelectorDef}
	,	ef_cons_defs		:: !.{# ConsDef}
	,	ef_member_defs		:: !.{# MemberDef}
	,	ef_class_defs		:: !.{# ClassDef}
93
	,	ef_generic_defs		:: !.{# GenericDef}
94
	,	ef_modules			:: !.{# DclModule}
95
	,	ef_macro_defs		:: !.{#.{#FunDef}}
96
97
98
99
	,	ef_is_macro_fun		:: !Bool
	}

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

101
addLocalFunctionDefsToSymbolTable :: !Level !Index !Index !Bool !*{#FunDef} !*SymbolTable !*ErrorAdmin -> (!*{# FunDef}, !*SymbolTable, !*ErrorAdmin)
102
addLocalDclMacroDefsToSymbolTable :: !Level !Int !Index !Index !*{#*{#FunDef}} !*SymbolTable !*ErrorAdmin -> (!*{#*{#FunDef}}, !*SymbolTable, !*ErrorAdmin)
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
103
addDefToSymbolTable :: !Level !Index !Ident !STE_Kind !*SymbolTable !*ErrorAdmin -> (!* SymbolTable, !*ErrorAdmin)
Martin Wierich's avatar
Martin Wierich committed
104
addDeclarationsOfDclModToSymbolTable :: .Int !{!Declaration} !{!Declaration} !*CheckState -> .CheckState;
105
addGlobalDefinitionsToSymbolTable :: ![Declaration] !*CheckState -> .CheckState;
Martin Wierich's avatar
Martin Wierich committed
106
107
addSymbol :: !(Optional a) !Ident !Position !STE_Kind !STE_Kind !.Int !.Int !Int !*CheckState -> (!Bool, !.CheckState)
addImportedFunctionOrMacro :: !(Optional IndexRange) !Ident !Int !*CheckState -> (!Bool, !.CheckState)
108

109
removeImportedSymbolsFromSymbolTable :: Declaration !*SymbolTable -> .SymbolTable
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
110
removeFieldFromSelectorDefinition :: !Ident .Int .Int !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry;
111
removeDeclarationsFromSymbolTable :: ![Declaration] !Int !*SymbolTable -> *SymbolTable
Ronny Wichers Schreur's avatar
Ronny Wichers Schreur committed
112
113
removeLocalIdentsFromSymbolTable :: .Int !.[Ident] !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry;
removeIdentFromSymbolTable :: !.Int !Ident !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry;
114
removeImportsAndLocalsOfModuleFromSymbolTable :: !Declarations !*(Heap SymbolTableEntry) -> .Heap SymbolTableEntry
115
116
removeLocalFunctionsFromSymbolTable :: !Level !IndexRange !*{# FunDef} !*(Heap SymbolTableEntry) -> (!.{# FunDef}, !.Heap SymbolTableEntry)
removeLocalDclMacrosFromSymbolTable :: !Level !Index !IndexRange !*{#*{#FunDef}} !*(Heap SymbolTableEntry) -> (!.{#.{#FunDef}}, !.Heap SymbolTableEntry)
117
118

newFreeVariable :: !FreeVar ![FreeVar] ->(!Bool, ![FreeVar])
119
120

local_declaration_for_import :: !u:Declaration .Index -> v:Declaration, [u <= v]
121
122
123
124
125
126
127

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

Martin Wierich's avatar
Martin Wierich committed
128
getBelongingSymbols :: !Declaration !v:{#DclModule} -> (!BelongingSymbols, !v:{#DclModule})
129
130
131
132
nrOfBelongingSymbols :: !BelongingSymbols -> Int

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