File: yfvinit.c

package info (click to toggle)
yforth 0.1beta-21
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 368 kB
  • ctags: 789
  • sloc: ansic: 4,424; makefile: 58
file content (192 lines) | stat: -rw-r--r-- 4,122 bytes parent folder | download | duplicates (9)
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/* yForth? - Written by Luca Padovani (C) 1996/97
 * ------------------------------------------------------------------------
 * This software is FreeWare as long as it comes with this header in each
 * source file, anyway you can use it or any part of it whatever
 * you want. It comes without any warranty, so use it at your own risk.
 * ------------------------------------------------------------------------
 * Module name:     yfvinit.c
 * Abstract:        Initialize the vocabulary.
 */

#include <string.h>
#include "yforth.h"
#include "core.h"
#include "ycore.h"
#if COREE_DEF
#	include "coree.h"
#endif
#if DOUBLE_DEF
#	include "double.h"
#endif
#if DOUBLEE_DEF
#	include	"doublee.h"
#endif
#if FLOAT_DEF
#	if !COREE_DEF
#		include "coree.h"
#	endif
#	include "float.h"
#endif
#if FLOATE_DEF
#	include	"floate.h"
#endif
#if MEMALL_DEF
#	include "memall.h"
#endif
#if SEARCH_DEF
#	include "search.h"
#endif
#if SEARCHE_DEF
#	include "searche.h"
#endif
#if TOOLS_DEF
#	include "tools.h"
#endif
#if TOOLSE_DEF
#	if !COREE_DEF
#		include "coree.h"
#	endif
#	include "toolse.h"
#endif
#if LOCALS_DEF
#	include "locals.h"
#endif
#if LOCALSE_DEF
#	include "localse.h"
#endif
#if FACILITY_DEF
#	include "facility.h"
#endif
#if FACILITYE_DEF
#	include "facilite.h"
#endif
#if STRING_DEF
#	include "string.h"
#endif
#if FILE_DEF
#	include "file.h"
#endif
#if	FILEE_DEF
#	include "filee.h"
#endif
#if BLOCK_DEF
#	include "block.h"
#endif
#if BLOCKE_DEF
#	include "blocke.h"
#endif
#if EXCEPTION_DEF
#	include "exceptio.h"
#endif
#if EXCEPTIONE_DEF
#	include "excepte.h"
#endif

static struct raw_voc iv[] = {
#define DECLARE_WORDS

#include "core.h"
#include "ycore.h"
#if COREE_DEF
#	include "coree.h"
#endif
#if DOUBLE_DEF
#	include "double.h"
#endif
#if DOUBLEE_DEF
#	include	"doublee.h"
#endif
#if FLOAT_DEF
#	include "float.h"
#endif
#if FLOATE_DEF
#	include	"floate.h"
#endif
#if MEMALL_DEF
#	include "memall.h"
#endif
#if SEARCH_DEF
#	include "search.h"
#endif
#if SEARCHE_DEF
#	include "searche.h"
#endif
#if TOOLS_DEF
#	include "tools.h"
#endif
#if TOOLSE_DEF
#	include "toolse.h"
#endif
#if LOCALS_DEF
#	include "locals.h"
#endif
#if LOCALSE_DEF
#	include "localse.h"
#endif
#if FACILITY_DEF
#	include "facility.h"
#endif
#if FACILITYE_DEF
#	include "facilite.h"
#endif
#ifdef STRING_DEF
#	include "string.h"
#endif
#if FILE_DEF
#	include "file.h"
#endif
#if	FILEE_DEF
#	include "filee.h"
#endif
#if BLOCK_DEF
#	include "block.h"
#endif
#if BLOCKE_DEF
#	include "blocke.h"
#endif
#if EXCEPTION_DEF
#	include "exceptio.h"
#endif
#if EXCEPTIONE_DEF
#	include "excepte.h"
#endif

	{ 0, 0, 0 },
};

#undef DECLARE_WORDS

/* init_vocabulary: loads words into the real dictionary from the table
 * builded by including all the header files after the declaration of
 * DECLARE_WORDS. See the header files such as "core.h" and the macro
 * file "macro.h" for the implementation of this.
 * This function returns the dictionary pointer after loading.
 */
void init_vocabulary(Char **dp) {
	struct word_def *w;
	Char *name;
	int i = 0;
    while (iv[i].name) {                /* Last name is a NULL (see table above) */
        name = *dp;                     /* "name" is a ptr to the name */
        **dp = strlen(iv[i].name);      /* first copy length... */
        strcpy(*dp + 1, iv[i].name);    /* ...and then the actual name */
        *dp = (Char *) WORD_PTR(*dp);   /* advance "dp" */
        w = (struct word_def *) *dp;    /* here begins the structure */
        w->name = name;                 /* adjust pointer... */
        w->class = iv[i].class;         /* ...and the class of the word */
        ins_word(w);                    /* Finally adjust the link field... */
        mark_word(w);                   /* ...accordingly with the hash function
                                           and make the word visible */
        *dp += sizeof(struct word_def); /* advance "dp" */
        switch (iv[i].class & A_WORD) {     /* The last field must be adjusted here */
			case A_PRIMITIVE:
				w->func[0] = iv[i].func;
				break;
			case A_USER:
				w->func[0] = (pfp) iv[i].func;
				break;
		}
		i++;
	}
}