aboutsummaryrefslogtreecommitdiff
path: root/backendC/CleanCompilerSources/typechecker_2.c
blob: 4f75cbd4e4f7c4f7734d1fc32d8a71d3c67482fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
	Version 1.2.3 26/03/1997

	Author:  Sjaak Smetsers
*/

#pragma options (!macsbug_names)

#include "compiledefines.h"
#include "types.t"
#include "system.h"
#include "settings.h"
#include "syntaxtr.t"
#include "comsupport.h"

#include "scanner.h"
#include "comparser.h"
#include "sizes.h"
#include "checker.h"
#include "checksupport.h"
#include "transform.h"
#include "sa.h"
#include "statesgen.h"
#include "tctypes.t"
#include "typechecker.h"
#include "typechecker2.h"
#include "typeconv.h"
#include "refcountanal.h"
#include "overloading.h"
#include "tcsupport.h"
#include "buildtree.h"
#include "version.h"

#ifdef _DEBUG_
	static char *TC = "typechecker";
#endif

#undef _TYPESBUG_

#ifdef _PRINTRULES_
#include "dbprint.h"
#endif

SymbDef ArrayDefs [NrOfArrayInstances];

void ListTypes (ImpMod imod)
{
	if (DoListAllTypes)
	{	ImpRules irule;
		for (irule = imod -> im_rules; irule; irule = irule -> rule_next)
		{	SymbDef imp_sdef = irule -> rule_root -> node_symbol -> symb_def;
		
#ifdef CLEAN2
			if (strncmp (imp_sdef->sdef_ident->ident_name, "_dictionary", 11) != 0 || imp_sdef->sdef_isused)
#endif
			PrintType (imp_sdef, irule -> rule_type);
		}
	}

} /* ListTypes */

PolyList UserDefinedArrayFunctions;

Bool TypeError;

FlatType RetrieveLhsOfTypeDefinition (SymbDef tdef)
{
	switch (tdef -> sdef_kind)
	{
	case TYPE:
	case RECORDTYPE:
		return tdef -> sdef_type != NULL ? tdef -> sdef_type -> type_lhs : NULL;
	case TYPESYN:
		return tdef -> sdef_syn_type -> syn_lhs;
		break;
	case ABSTYPE:
		return tdef -> sdef_abs_type -> abs_graph;
		break;
	default:
		return NULL;
	}

} /* RetrieveLhsOfTypeDefinition */

HeapDescr TCTempSpace;

void InitTypeChecker (void)
{
#ifndef CLEAN2
	EmptySymbol = CompAllocType (SymbolS);
	EmptySymbol -> symb_kind = empty_symbol;

	InitialCellInfo.ci_removed		= False;
	InitialCellInfo.ci_free			= False;
	InitialCellInfo.ci_mark			= False;
	InitialCellInfo.ci_expanded		= False;
	InitialCellInfo.ci_printed		= False;
	InitialCellInfo.ci_hidden		= False;
	InitialCellInfo.ci_overloaded		= False;
	InitialCellInfo.ci_no_match		= False;
	InitialCellInfo.ci_class_var		= False;
	InitialCellInfo.ci_tmp_cell		= False;
	InitialCellInfo.ci_copy_cell		= False;
	InitialCellInfo.ci_strict		= False;
	InitialCellInfo.ci_with_insres	= False;
	InitialCellInfo.ci_non_coercible	= False;
	InitialCellInfo.ci_default		= False;

	InitialCellInfo.ci_kind			= BasicType;
	InitialCellInfo.ci_attrkind		= AC_NotUnique;
	InitialCellInfo.ci_attrvarkind	= AVK_Plain;
	InitialCellInfo.ci_instdepth		= 0;

	InitialTempAttrVar.tav_mark 			= False;
	InitialTempAttrVar.tav_present		= False;
	InitialTempAttrVar.tav_free			= False;
	InitialTempAttrVar.tav_onstack		= False;
	InitialTempAttrVar.tav_exi_quanti		= False;
	InitialTempAttrVar.tav_non_coercible	= False;
	
	InitialTempAttrVar.tav_varkind		= AC_Variable;
	InitialTempAttrVar.tav_number			= 0;
	InitialTempAttrVar.tav_offered		= NULL;
	InitialTempAttrVar.tav_demanded		= NULL;
#endif
}