checker_2.c 3.08 KB
Newer Older
clean's avatar
clean committed
1
2
3
4
5
/*
	Authors:	Sjaak Smetsers & John van Groningen
	Version:	1.2
*/

6
#include "compiledefines.h"
clean's avatar
clean committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "types.t"
#include "system.h"
#include "syntaxtr.t"
#include "comsupport.h"
#include "sizes.h"
#include "scanner.h"
#include "buildtree.h"
#include "comparser.h"
#include "statesgen.h"
#include "codegen_types.h"
#include "codegen1.h"
#include "codegen2.h"
#include "instructions.h"
#include "checksupport.h"
#include "settings.h"
#include "checker.h"
#ifdef applec
#	include <types.h>
#endif

#define for_l(v,l,n) for(v=(l);v!=NULL;v=v->n)

typedef struct def_list *DefModList,DefModElem;

31
struct def_list *OpenDefinitionModules;
clean's avatar
clean committed
32
33
34
35
36
37

void GenDependencyList (void)
{
	DefModList def_mod;

	for_l (def_mod,OpenDefinitionModules,mod_next)
38
		GenDepend (def_mod->mod_body->dm_name
clean's avatar
clean committed
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#if WRITE_DCL_MODIFICATION_TIME
					,def_mod->mod_body->dm_modification_time
#endif
					);
}

void ReadInlineCode (void)
{
	DefModList d_mod;

	for_l (d_mod,OpenDefinitionModules,mod_next){
		DefMod def_mod;
		
		def_mod=d_mod->mod_body;
		if (def_mod->dm_system_module){
54
55
			int i,n_function_symbols;
			Symbol function_symbol_a;
clean's avatar
clean committed
56
			
57
58
59
60
			n_function_symbols=def_mod->dm_n_function_symbols;
			function_symbol_a=def_mod->dm_function_symbol_a;
			for (i=0; i<n_function_symbols; ++i)
				if (function_symbol_a[i].symb_kind==definition){
clean's avatar
clean committed
61
62
					SymbDef sdef;

63
					sdef=function_symbol_a[i].symb_def;
clean's avatar
clean committed
64
65
66
					if (sdef->sdef_kind==SYSRULE && sdef->sdef_mark & SDEF_USED_STRICTLY_MASK)
						break;
				}
67
68

			if (i<n_function_symbols && d_mod->mod_name->symb_ident->ident_name!=CurrentModule)
clean's avatar
clean committed
69
				/* Get the inline instructions of all the rules that are defined in this module */
70
				ScanInlineFile (d_mod->mod_name->symb_ident->ident_name,FirstSystemModuleTable+def_mod->dm_module_n);
clean's avatar
clean committed
71
72
73
74
		}
	}
}

75
Ident ApplyId, DynamicId, StdBoolId, IfId, FailId, AndId, OrId;
clean's avatar
clean committed
76

77
78
79
80
#if SA_RECOGNIZES_ABORT_AND_UNDEF
Ident StdMiscId,abort_id,undef_id;	
#endif

John van Groningen's avatar
add seq    
John van Groningen committed
81
82
Ident PreludeId,seq_id,system_seq_id;

clean's avatar
clean committed
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
Symbol StartSymbol;

SymbDef ArrayFunctionDefs [NoArrayFun],StdArrayAbortDef;

SymbDef scc_dependency_list;

SymbDef MakeNewSymbolDefinition (char * module, Ident name, int arity, SDefKind kind)
{
	SymbDef def;
	
	def = CompAllocType (SymbDefS);
	
	def->sdef_module = module;
	def->sdef_ident = name;
	def->sdef_arity = arity;
	def->sdef_kind = kind;

	def->sdef_mark=0;

	def->sdef_exported=False;

	def->sdef_arfun				= NoArrayFun;
	
	return def;
}

NodeDefs NewNodeDef (NodeId nid,Node node)
{
	NodeDefs new;

113
	new = CompAllocType (NodeDefS);
clean's avatar
clean committed
114
115
116
117
118
119
120
121
122
123
124

	new->def_id		= nid;
	new->def_node	= node;
	new->def_mark	= 0;

	return new;
}

void InitChecker (void)
{
	StartSymbol = NewSymbol (newsymbol);
125
	StartSymbol -> symb_ident = NewIdent ("Start");
clean's avatar
clean committed
126

127
	system_seq_id = NewIdent ("seq");
John van Groningen's avatar
add seq    
John van Groningen committed
128

clean's avatar
clean committed
129
130
131
	OpenDefinitionModules	= NIL;
}

John van Groningen's avatar
John van Groningen committed
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
void ClearOpenDefinitionModules (void)
{
	OpenDefinitionModules	= NULL;
}

void AddOpenDefinitionModule (SymbolP moduleNameSymbol, DefMod definitionModule)
{
	DefModList	openModule;

	openModule = CompAllocType (DefModElem);
	openModule->mod_name	= moduleNameSymbol;
	openModule->mod_body	= definitionModule;
	openModule->mod_next	= OpenDefinitionModules;

	OpenDefinitionModules  = openModule;
}