kanayago 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rubocop.yml +15 -0
- data/.rubocop_todo.yml +23 -0
- data/LICENSE.txt +21 -0
- data/README.md +79 -0
- data/Rakefile +182 -0
- data/ext/kanayago/ccan/check_type/check_type.h +63 -0
- data/ext/kanayago/ccan/container_of/container_of.h +142 -0
- data/ext/kanayago/ccan/list/list.h +791 -0
- data/ext/kanayago/ccan/str/str.h +17 -0
- data/ext/kanayago/constant.h +53 -0
- data/ext/kanayago/extconf.rb +21 -0
- data/ext/kanayago/id.h +347 -0
- data/ext/kanayago/id_table.h +39 -0
- data/ext/kanayago/internal/array.h +151 -0
- data/ext/kanayago/internal/basic_operators.h +64 -0
- data/ext/kanayago/internal/bignum.h +244 -0
- data/ext/kanayago/internal/bits.h +568 -0
- data/ext/kanayago/internal/compile.h +34 -0
- data/ext/kanayago/internal/compilers.h +107 -0
- data/ext/kanayago/internal/complex.h +29 -0
- data/ext/kanayago/internal/encoding.h +36 -0
- data/ext/kanayago/internal/error.h +218 -0
- data/ext/kanayago/internal/fixnum.h +184 -0
- data/ext/kanayago/internal/gc.h +322 -0
- data/ext/kanayago/internal/hash.h +191 -0
- data/ext/kanayago/internal/imemo.h +261 -0
- data/ext/kanayago/internal/io.h +140 -0
- data/ext/kanayago/internal/numeric.h +274 -0
- data/ext/kanayago/internal/parse.h +117 -0
- data/ext/kanayago/internal/rational.h +71 -0
- data/ext/kanayago/internal/re.h +28 -0
- data/ext/kanayago/internal/ruby_parser.h +125 -0
- data/ext/kanayago/internal/sanitizers.h +297 -0
- data/ext/kanayago/internal/serial.h +23 -0
- data/ext/kanayago/internal/static_assert.h +16 -0
- data/ext/kanayago/internal/string.h +186 -0
- data/ext/kanayago/internal/symbol.h +45 -0
- data/ext/kanayago/internal/thread.h +79 -0
- data/ext/kanayago/internal/variable.h +72 -0
- data/ext/kanayago/internal/vm.h +137 -0
- data/ext/kanayago/internal/warnings.h +16 -0
- data/ext/kanayago/internal.h +108 -0
- data/ext/kanayago/kanayago.c +420 -0
- data/ext/kanayago/kanayago.h +21 -0
- data/ext/kanayago/lex.c +302 -0
- data/ext/kanayago/method.h +255 -0
- data/ext/kanayago/node.c +440 -0
- data/ext/kanayago/node.h +111 -0
- data/ext/kanayago/node_name.inc +224 -0
- data/ext/kanayago/parse.c +26931 -0
- data/ext/kanayago/parse.h +244 -0
- data/ext/kanayago/parse.tmp.y +16145 -0
- data/ext/kanayago/parser_bits.h +564 -0
- data/ext/kanayago/parser_node.h +32 -0
- data/ext/kanayago/parser_st.c +164 -0
- data/ext/kanayago/parser_st.h +162 -0
- data/ext/kanayago/parser_value.h +106 -0
- data/ext/kanayago/probes.h +4 -0
- data/ext/kanayago/ruby_assert.h +14 -0
- data/ext/kanayago/ruby_atomic.h +23 -0
- data/ext/kanayago/ruby_parser.c +1165 -0
- data/ext/kanayago/rubyparser.h +1391 -0
- data/ext/kanayago/shape.h +234 -0
- data/ext/kanayago/st.c +2339 -0
- data/ext/kanayago/symbol.h +123 -0
- data/ext/kanayago/thread_pthread.h +168 -0
- data/ext/kanayago/universal_parser.c +230 -0
- data/ext/kanayago/vm_core.h +2215 -0
- data/ext/kanayago/vm_opts.h +67 -0
- data/lib/kanayago/version.rb +5 -0
- data/lib/kanayago.rb +11 -0
- data/sig/kanayago.rbs +4 -0
- metadata +116 -0
data/ext/kanayago/lex.c
ADDED
@@ -0,0 +1,302 @@
|
|
1
|
+
/* ANSI-C code produced by gperf version 3.1 */
|
2
|
+
/* Command-line: gperf -C -L ANSI-C -P -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' defs/keywords */
|
3
|
+
|
4
|
+
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
|
5
|
+
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
|
6
|
+
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
|
7
|
+
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
|
8
|
+
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
|
9
|
+
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
|
10
|
+
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
|
11
|
+
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
|
12
|
+
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
|
13
|
+
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
|
14
|
+
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
|
15
|
+
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
|
16
|
+
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
|
17
|
+
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
|
18
|
+
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
|
19
|
+
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
|
20
|
+
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
|
21
|
+
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
|
22
|
+
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
|
23
|
+
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
|
24
|
+
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
|
25
|
+
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
|
26
|
+
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
|
27
|
+
/* The character set is not based on ISO-646. */
|
28
|
+
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
|
29
|
+
#endif
|
30
|
+
|
31
|
+
#line 1 "defs/keywords"
|
32
|
+
|
33
|
+
struct kwtable {short name, id[2], state;};
|
34
|
+
const struct kwtable *rb_reserved_word(const char *, unsigned int);
|
35
|
+
#ifndef RIPPER
|
36
|
+
static const struct kwtable *reserved_word(register const char *str, register size_t len);
|
37
|
+
#define rb_reserved_word(str, len) reserved_word(str, len)
|
38
|
+
#line 9 "defs/keywords"
|
39
|
+
struct kwtable;
|
40
|
+
|
41
|
+
#define TOTAL_KEYWORDS 41
|
42
|
+
#define MIN_WORD_LENGTH 2
|
43
|
+
#define MAX_WORD_LENGTH 12
|
44
|
+
#define MIN_HASH_VALUE 8
|
45
|
+
#define MAX_HASH_VALUE 50
|
46
|
+
/* maximum key range = 43, duplicates = 0 */
|
47
|
+
|
48
|
+
#ifdef __GNUC__
|
49
|
+
__inline
|
50
|
+
#else
|
51
|
+
#ifdef __cplusplus
|
52
|
+
inline
|
53
|
+
#endif
|
54
|
+
#endif
|
55
|
+
static unsigned int
|
56
|
+
hash (register const char *str, register size_t len)
|
57
|
+
{
|
58
|
+
static const unsigned char asso_values[] =
|
59
|
+
{
|
60
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
61
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
62
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
63
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
64
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
65
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
66
|
+
51, 51, 51, 26, 51, 51, 14, 51, 16, 8,
|
67
|
+
11, 13, 51, 51, 51, 51, 10, 51, 13, 51,
|
68
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
69
|
+
51, 51, 51, 51, 51, 11, 51, 13, 1, 26,
|
70
|
+
4, 1, 8, 28, 51, 23, 51, 1, 1, 27,
|
71
|
+
5, 19, 21, 51, 8, 3, 3, 11, 51, 21,
|
72
|
+
24, 16, 51, 51, 51, 51, 51, 51, 51, 51,
|
73
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
74
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
75
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
76
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
77
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
78
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
79
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
80
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
81
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
82
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
83
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
84
|
+
51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
|
85
|
+
51, 51, 51, 51, 51, 51
|
86
|
+
};
|
87
|
+
register unsigned int hval = (unsigned int)len;
|
88
|
+
|
89
|
+
switch (hval)
|
90
|
+
{
|
91
|
+
default:
|
92
|
+
hval += asso_values[(unsigned char)str[2]];
|
93
|
+
/*FALLTHROUGH*/
|
94
|
+
case 2:
|
95
|
+
case 1:
|
96
|
+
hval += asso_values[(unsigned char)str[0]];
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
return (unsigned int)hval + asso_values[(unsigned char)str[len - 1]];
|
100
|
+
}
|
101
|
+
|
102
|
+
struct stringpool_t
|
103
|
+
{
|
104
|
+
char stringpool_str8[sizeof("break")];
|
105
|
+
char stringpool_str9[sizeof("else")];
|
106
|
+
char stringpool_str10[sizeof("nil")];
|
107
|
+
char stringpool_str11[sizeof("ensure")];
|
108
|
+
char stringpool_str12[sizeof("end")];
|
109
|
+
char stringpool_str13[sizeof("then")];
|
110
|
+
char stringpool_str14[sizeof("not")];
|
111
|
+
char stringpool_str15[sizeof("false")];
|
112
|
+
char stringpool_str16[sizeof("self")];
|
113
|
+
char stringpool_str17[sizeof("elsif")];
|
114
|
+
char stringpool_str18[sizeof("rescue")];
|
115
|
+
char stringpool_str19[sizeof("true")];
|
116
|
+
char stringpool_str20[sizeof("until")];
|
117
|
+
char stringpool_str21[sizeof("unless")];
|
118
|
+
char stringpool_str22[sizeof("return")];
|
119
|
+
char stringpool_str23[sizeof("def")];
|
120
|
+
char stringpool_str24[sizeof("and")];
|
121
|
+
char stringpool_str25[sizeof("do")];
|
122
|
+
char stringpool_str26[sizeof("yield")];
|
123
|
+
char stringpool_str27[sizeof("for")];
|
124
|
+
char stringpool_str28[sizeof("undef")];
|
125
|
+
char stringpool_str29[sizeof("or")];
|
126
|
+
char stringpool_str30[sizeof("in")];
|
127
|
+
char stringpool_str31[sizeof("when")];
|
128
|
+
char stringpool_str32[sizeof("retry")];
|
129
|
+
char stringpool_str33[sizeof("if")];
|
130
|
+
char stringpool_str34[sizeof("case")];
|
131
|
+
char stringpool_str35[sizeof("redo")];
|
132
|
+
char stringpool_str36[sizeof("next")];
|
133
|
+
char stringpool_str37[sizeof("super")];
|
134
|
+
char stringpool_str38[sizeof("module")];
|
135
|
+
char stringpool_str39[sizeof("begin")];
|
136
|
+
char stringpool_str40[sizeof("__LINE__")];
|
137
|
+
char stringpool_str41[sizeof("__FILE__")];
|
138
|
+
char stringpool_str42[sizeof("__ENCODING__")];
|
139
|
+
char stringpool_str43[sizeof("END")];
|
140
|
+
char stringpool_str44[sizeof("alias")];
|
141
|
+
char stringpool_str45[sizeof("BEGIN")];
|
142
|
+
char stringpool_str46[sizeof("defined?")];
|
143
|
+
char stringpool_str47[sizeof("class")];
|
144
|
+
char stringpool_str50[sizeof("while")];
|
145
|
+
};
|
146
|
+
static const struct stringpool_t stringpool_contents =
|
147
|
+
{
|
148
|
+
"break",
|
149
|
+
"else",
|
150
|
+
"nil",
|
151
|
+
"ensure",
|
152
|
+
"end",
|
153
|
+
"then",
|
154
|
+
"not",
|
155
|
+
"false",
|
156
|
+
"self",
|
157
|
+
"elsif",
|
158
|
+
"rescue",
|
159
|
+
"true",
|
160
|
+
"until",
|
161
|
+
"unless",
|
162
|
+
"return",
|
163
|
+
"def",
|
164
|
+
"and",
|
165
|
+
"do",
|
166
|
+
"yield",
|
167
|
+
"for",
|
168
|
+
"undef",
|
169
|
+
"or",
|
170
|
+
"in",
|
171
|
+
"when",
|
172
|
+
"retry",
|
173
|
+
"if",
|
174
|
+
"case",
|
175
|
+
"redo",
|
176
|
+
"next",
|
177
|
+
"super",
|
178
|
+
"module",
|
179
|
+
"begin",
|
180
|
+
"__LINE__",
|
181
|
+
"__FILE__",
|
182
|
+
"__ENCODING__",
|
183
|
+
"END",
|
184
|
+
"alias",
|
185
|
+
"BEGIN",
|
186
|
+
"defined?",
|
187
|
+
"class",
|
188
|
+
"while"
|
189
|
+
};
|
190
|
+
#define stringpool ((const char *) &stringpool_contents)
|
191
|
+
const struct kwtable *
|
192
|
+
rb_reserved_word (register const char *str, register size_t len)
|
193
|
+
{
|
194
|
+
static const struct kwtable wordlist[] =
|
195
|
+
{
|
196
|
+
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
|
197
|
+
#line 19 "defs/keywords"
|
198
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str8, {keyword_break, keyword_break}, EXPR_MID},
|
199
|
+
#line 25 "defs/keywords"
|
200
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str9, {keyword_else, keyword_else}, EXPR_BEG},
|
201
|
+
#line 35 "defs/keywords"
|
202
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str10, {keyword_nil, keyword_nil}, EXPR_END},
|
203
|
+
#line 28 "defs/keywords"
|
204
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str11, {keyword_ensure, keyword_ensure}, EXPR_BEG},
|
205
|
+
#line 27 "defs/keywords"
|
206
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str12, {keyword_end, keyword_end}, EXPR_END},
|
207
|
+
#line 44 "defs/keywords"
|
208
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str13, {keyword_then, keyword_then}, EXPR_BEG},
|
209
|
+
#line 36 "defs/keywords"
|
210
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str14, {keyword_not, keyword_not}, EXPR_ARG},
|
211
|
+
#line 29 "defs/keywords"
|
212
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str15, {keyword_false, keyword_false}, EXPR_END},
|
213
|
+
#line 42 "defs/keywords"
|
214
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str16, {keyword_self, keyword_self}, EXPR_END},
|
215
|
+
#line 26 "defs/keywords"
|
216
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str17, {keyword_elsif, keyword_elsif}, EXPR_VALUE},
|
217
|
+
#line 39 "defs/keywords"
|
218
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str18, {keyword_rescue, modifier_rescue}, EXPR_MID},
|
219
|
+
#line 45 "defs/keywords"
|
220
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str19, {keyword_true, keyword_true}, EXPR_END},
|
221
|
+
#line 48 "defs/keywords"
|
222
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str20, {keyword_until, modifier_until}, EXPR_VALUE},
|
223
|
+
#line 47 "defs/keywords"
|
224
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str21, {keyword_unless, modifier_unless}, EXPR_VALUE},
|
225
|
+
#line 41 "defs/keywords"
|
226
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str22, {keyword_return, keyword_return}, EXPR_MID},
|
227
|
+
#line 22 "defs/keywords"
|
228
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str23, {keyword_def, keyword_def}, EXPR_FNAME},
|
229
|
+
#line 17 "defs/keywords"
|
230
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str24, {keyword_and, keyword_and}, EXPR_VALUE},
|
231
|
+
#line 24 "defs/keywords"
|
232
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str25, {keyword_do, keyword_do}, EXPR_BEG},
|
233
|
+
#line 51 "defs/keywords"
|
234
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str26, {keyword_yield, keyword_yield}, EXPR_ARG},
|
235
|
+
#line 30 "defs/keywords"
|
236
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str27, {keyword_for, keyword_for}, EXPR_VALUE},
|
237
|
+
#line 46 "defs/keywords"
|
238
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str28, {keyword_undef, keyword_undef}, EXPR_FNAME|EXPR_FITEM},
|
239
|
+
#line 37 "defs/keywords"
|
240
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str29, {keyword_or, keyword_or}, EXPR_VALUE},
|
241
|
+
#line 32 "defs/keywords"
|
242
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str30, {keyword_in, keyword_in}, EXPR_VALUE},
|
243
|
+
#line 49 "defs/keywords"
|
244
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str31, {keyword_when, keyword_when}, EXPR_VALUE},
|
245
|
+
#line 40 "defs/keywords"
|
246
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str32, {keyword_retry, keyword_retry}, EXPR_END},
|
247
|
+
#line 31 "defs/keywords"
|
248
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str33, {keyword_if, modifier_if}, EXPR_VALUE},
|
249
|
+
#line 20 "defs/keywords"
|
250
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str34, {keyword_case, keyword_case}, EXPR_VALUE},
|
251
|
+
#line 38 "defs/keywords"
|
252
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str35, {keyword_redo, keyword_redo}, EXPR_END},
|
253
|
+
#line 34 "defs/keywords"
|
254
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str36, {keyword_next, keyword_next}, EXPR_MID},
|
255
|
+
#line 43 "defs/keywords"
|
256
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str37, {keyword_super, keyword_super}, EXPR_ARG},
|
257
|
+
#line 33 "defs/keywords"
|
258
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str38, {keyword_module, keyword_module}, EXPR_VALUE},
|
259
|
+
#line 18 "defs/keywords"
|
260
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str39, {keyword_begin, keyword_begin}, EXPR_BEG},
|
261
|
+
#line 12 "defs/keywords"
|
262
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str40, {keyword__LINE__, keyword__LINE__}, EXPR_END},
|
263
|
+
#line 13 "defs/keywords"
|
264
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str41, {keyword__FILE__, keyword__FILE__}, EXPR_END},
|
265
|
+
#line 11 "defs/keywords"
|
266
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str42, {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END},
|
267
|
+
#line 15 "defs/keywords"
|
268
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str43, {keyword_END, keyword_END}, EXPR_END},
|
269
|
+
#line 16 "defs/keywords"
|
270
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str44, {keyword_alias, keyword_alias}, EXPR_FNAME|EXPR_FITEM},
|
271
|
+
#line 14 "defs/keywords"
|
272
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str45, {keyword_BEGIN, keyword_BEGIN}, EXPR_END},
|
273
|
+
#line 23 "defs/keywords"
|
274
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str46, {keyword_defined, keyword_defined}, EXPR_ARG},
|
275
|
+
#line 21 "defs/keywords"
|
276
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str47, {keyword_class, keyword_class}, EXPR_CLASS},
|
277
|
+
{-1}, {-1},
|
278
|
+
#line 50 "defs/keywords"
|
279
|
+
{(int)(size_t)&((struct stringpool_t *)0)->stringpool_str50, {keyword_while, modifier_while}, EXPR_VALUE}
|
280
|
+
};
|
281
|
+
|
282
|
+
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
283
|
+
{
|
284
|
+
register unsigned int key = hash (str, len);
|
285
|
+
|
286
|
+
if (key <= MAX_HASH_VALUE)
|
287
|
+
{
|
288
|
+
register int o = wordlist[key].name;
|
289
|
+
if (o >= 0)
|
290
|
+
{
|
291
|
+
register const char *s = o + stringpool;
|
292
|
+
|
293
|
+
if (*str == *s && !strcmp (str + 1, s + 1))
|
294
|
+
return &wordlist[key];
|
295
|
+
}
|
296
|
+
}
|
297
|
+
}
|
298
|
+
return 0;
|
299
|
+
}
|
300
|
+
#line 52 "defs/keywords"
|
301
|
+
|
302
|
+
#endif
|
@@ -0,0 +1,255 @@
|
|
1
|
+
#ifndef RUBY_METHOD_H
|
2
|
+
#define RUBY_METHOD_H 1
|
3
|
+
/**********************************************************************
|
4
|
+
|
5
|
+
method.h -
|
6
|
+
|
7
|
+
$Author$
|
8
|
+
created at: Wed Jul 15 20:02:33 2009
|
9
|
+
|
10
|
+
Copyright (C) 2009 Koichi Sasada
|
11
|
+
|
12
|
+
**********************************************************************/
|
13
|
+
|
14
|
+
#include "internal.h"
|
15
|
+
#include "internal/imemo.h"
|
16
|
+
#include "internal/compilers.h"
|
17
|
+
#include "internal/static_assert.h"
|
18
|
+
|
19
|
+
#ifndef END_OF_ENUMERATION
|
20
|
+
# if defined(__GNUC__) &&! defined(__STRICT_ANSI__)
|
21
|
+
# define END_OF_ENUMERATION(key)
|
22
|
+
# else
|
23
|
+
# define END_OF_ENUMERATION(key) END_OF_##key##_PLACEHOLDER = 0
|
24
|
+
# endif
|
25
|
+
#endif
|
26
|
+
|
27
|
+
/* cref */
|
28
|
+
|
29
|
+
typedef enum {
|
30
|
+
METHOD_VISI_UNDEF = 0x00,
|
31
|
+
METHOD_VISI_PUBLIC = 0x01,
|
32
|
+
METHOD_VISI_PRIVATE = 0x02,
|
33
|
+
METHOD_VISI_PROTECTED = 0x03,
|
34
|
+
|
35
|
+
METHOD_VISI_MASK = 0x03
|
36
|
+
} rb_method_visibility_t;
|
37
|
+
|
38
|
+
typedef struct rb_scope_visi_struct {
|
39
|
+
BITFIELD(rb_method_visibility_t, method_visi, 3);
|
40
|
+
unsigned int module_func : 1;
|
41
|
+
} rb_scope_visibility_t;
|
42
|
+
|
43
|
+
/*! CREF (Class REFerence) */
|
44
|
+
typedef struct rb_cref_struct {
|
45
|
+
VALUE flags;
|
46
|
+
VALUE refinements;
|
47
|
+
VALUE klass_or_self;
|
48
|
+
struct rb_cref_struct * next;
|
49
|
+
const rb_scope_visibility_t scope_visi;
|
50
|
+
} rb_cref_t;
|
51
|
+
|
52
|
+
/* method data type */
|
53
|
+
|
54
|
+
typedef struct rb_method_entry_struct {
|
55
|
+
VALUE flags;
|
56
|
+
VALUE defined_class;
|
57
|
+
struct rb_method_definition_struct * const def;
|
58
|
+
ID called_id;
|
59
|
+
VALUE owner;
|
60
|
+
} rb_method_entry_t;
|
61
|
+
|
62
|
+
typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_entry_t */
|
63
|
+
VALUE flags;
|
64
|
+
const VALUE defined_class;
|
65
|
+
struct rb_method_definition_struct * const def;
|
66
|
+
ID called_id;
|
67
|
+
const VALUE owner;
|
68
|
+
} rb_callable_method_entry_t;
|
69
|
+
|
70
|
+
#define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
|
71
|
+
#define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
|
72
|
+
#define METHOD_ENTRY_COMPLEMENTED(me) ((me)->flags & IMEMO_FL_USER3)
|
73
|
+
#define METHOD_ENTRY_COMPLEMENTED_SET(me) ((me)->flags |= IMEMO_FL_USER3)
|
74
|
+
#define METHOD_ENTRY_CACHED(me) ((me)->flags & IMEMO_FL_USER4)
|
75
|
+
#define METHOD_ENTRY_CACHED_SET(me) ((me)->flags |= IMEMO_FL_USER4)
|
76
|
+
#define METHOD_ENTRY_INVALIDATED(me) ((me)->flags & IMEMO_FL_USER5)
|
77
|
+
#define METHOD_ENTRY_INVALIDATED_SET(me) ((me)->flags |= IMEMO_FL_USER5)
|
78
|
+
|
79
|
+
static inline void
|
80
|
+
METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
|
81
|
+
{
|
82
|
+
VM_ASSERT((int)visi >= 0 && visi <= 3);
|
83
|
+
me->flags = (me->flags & ~(IMEMO_FL_USER0 | IMEMO_FL_USER1)) | (visi << (IMEMO_FL_USHIFT+0));
|
84
|
+
}
|
85
|
+
static inline void
|
86
|
+
METHOD_ENTRY_BASIC_SET(rb_method_entry_t *me, unsigned int basic)
|
87
|
+
{
|
88
|
+
VM_ASSERT(basic <= 1);
|
89
|
+
me->flags = (me->flags & ~(IMEMO_FL_USER2 )) | (basic << (IMEMO_FL_USHIFT+2));
|
90
|
+
}
|
91
|
+
static inline void
|
92
|
+
METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, unsigned int basic)
|
93
|
+
{
|
94
|
+
VM_ASSERT((int)visi >= 0 && visi <= 3);
|
95
|
+
VM_ASSERT(basic <= 1);
|
96
|
+
me->flags =
|
97
|
+
(me->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
|
98
|
+
((visi << (IMEMO_FL_USHIFT+0)) | (basic << (IMEMO_FL_USHIFT+2)));
|
99
|
+
}
|
100
|
+
static inline void
|
101
|
+
METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
|
102
|
+
{
|
103
|
+
dst->flags =
|
104
|
+
(dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2
|
105
|
+
|IMEMO_FL_USER3)) |
|
106
|
+
(src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2|IMEMO_FL_USER3));
|
107
|
+
}
|
108
|
+
|
109
|
+
typedef enum {
|
110
|
+
VM_METHOD_TYPE_ISEQ, /*!< Ruby method */
|
111
|
+
VM_METHOD_TYPE_CFUNC, /*!< C method */
|
112
|
+
VM_METHOD_TYPE_ATTRSET, /*!< attr_writer or attr_accessor */
|
113
|
+
VM_METHOD_TYPE_IVAR, /*!< attr_reader or attr_accessor */
|
114
|
+
VM_METHOD_TYPE_BMETHOD,
|
115
|
+
VM_METHOD_TYPE_ZSUPER,
|
116
|
+
VM_METHOD_TYPE_ALIAS,
|
117
|
+
VM_METHOD_TYPE_UNDEF,
|
118
|
+
VM_METHOD_TYPE_NOTIMPLEMENTED,
|
119
|
+
VM_METHOD_TYPE_OPTIMIZED, /*!< Kernel#send, Proc#call, etc */
|
120
|
+
VM_METHOD_TYPE_MISSING, /*!< wrapper for method_missing(id) */
|
121
|
+
VM_METHOD_TYPE_REFINED, /*!< refinement */
|
122
|
+
|
123
|
+
END_OF_ENUMERATION(VM_METHOD_TYPE)
|
124
|
+
} rb_method_type_t;
|
125
|
+
#define VM_METHOD_TYPE_MINIMUM_BITS 4
|
126
|
+
STATIC_ASSERT(VM_METHOD_TYPE_MINIMUM_BITS,
|
127
|
+
VM_METHOD_TYPE_REFINED <= (1<<VM_METHOD_TYPE_MINIMUM_BITS));
|
128
|
+
|
129
|
+
#ifndef rb_iseq_t
|
130
|
+
typedef struct rb_iseq_struct rb_iseq_t;
|
131
|
+
#define rb_iseq_t rb_iseq_t
|
132
|
+
#endif
|
133
|
+
|
134
|
+
typedef struct rb_method_iseq_struct {
|
135
|
+
const rb_iseq_t * iseqptr; /*!< iseq pointer, should be separated from iseqval */
|
136
|
+
rb_cref_t * cref; /*!< class reference, should be marked */
|
137
|
+
} rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */
|
138
|
+
|
139
|
+
typedef VALUE (*rb_cfunc_t)(ANYARGS);
|
140
|
+
typedef struct rb_method_cfunc_struct {
|
141
|
+
rb_cfunc_t func;
|
142
|
+
VALUE (*invoker)(VALUE recv, int argc, const VALUE *argv, VALUE (*func)(ANYARGS));
|
143
|
+
int argc;
|
144
|
+
} rb_method_cfunc_t;
|
145
|
+
|
146
|
+
typedef struct rb_method_attr_struct {
|
147
|
+
ID id;
|
148
|
+
VALUE location; /* should be marked */
|
149
|
+
} rb_method_attr_t;
|
150
|
+
|
151
|
+
typedef struct rb_method_alias_struct {
|
152
|
+
struct rb_method_entry_struct * original_me; /* original_me->klass is original owner */
|
153
|
+
} rb_method_alias_t;
|
154
|
+
|
155
|
+
typedef struct rb_method_refined_struct {
|
156
|
+
struct rb_method_entry_struct * orig_me;
|
157
|
+
} rb_method_refined_t;
|
158
|
+
|
159
|
+
typedef struct rb_method_bmethod_struct {
|
160
|
+
VALUE proc; /* should be marked */
|
161
|
+
struct rb_hook_list_struct *hooks;
|
162
|
+
VALUE defined_ractor;
|
163
|
+
} rb_method_bmethod_t;
|
164
|
+
|
165
|
+
enum method_optimized_type {
|
166
|
+
OPTIMIZED_METHOD_TYPE_SEND,
|
167
|
+
OPTIMIZED_METHOD_TYPE_CALL,
|
168
|
+
OPTIMIZED_METHOD_TYPE_BLOCK_CALL,
|
169
|
+
OPTIMIZED_METHOD_TYPE_STRUCT_AREF,
|
170
|
+
OPTIMIZED_METHOD_TYPE_STRUCT_ASET,
|
171
|
+
OPTIMIZED_METHOD_TYPE__MAX
|
172
|
+
};
|
173
|
+
|
174
|
+
typedef struct rb_method_optimized {
|
175
|
+
enum method_optimized_type type;
|
176
|
+
unsigned int index;
|
177
|
+
} rb_method_optimized_t;
|
178
|
+
|
179
|
+
struct rb_method_definition_struct {
|
180
|
+
BITFIELD(rb_method_type_t, type, VM_METHOD_TYPE_MINIMUM_BITS);
|
181
|
+
unsigned int iseq_overload: 1;
|
182
|
+
unsigned int no_redef_warning: 1;
|
183
|
+
unsigned int aliased : 1;
|
184
|
+
int reference_count : 28;
|
185
|
+
|
186
|
+
union {
|
187
|
+
rb_method_iseq_t iseq;
|
188
|
+
rb_method_cfunc_t cfunc;
|
189
|
+
rb_method_attr_t attr;
|
190
|
+
rb_method_alias_t alias;
|
191
|
+
rb_method_refined_t refined;
|
192
|
+
rb_method_bmethod_t bmethod;
|
193
|
+
rb_method_optimized_t optimized;
|
194
|
+
} body;
|
195
|
+
|
196
|
+
ID original_id;
|
197
|
+
uintptr_t method_serial;
|
198
|
+
};
|
199
|
+
|
200
|
+
struct rb_id_table;
|
201
|
+
|
202
|
+
typedef struct rb_method_definition_struct rb_method_definition_t;
|
203
|
+
STATIC_ASSERT(sizeof_method_def, offsetof(rb_method_definition_t, body) <= 8);
|
204
|
+
|
205
|
+
#define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
|
206
|
+
#define UNDEFINED_REFINED_METHOD_P(def) \
|
207
|
+
((def)->type == VM_METHOD_TYPE_REFINED && \
|
208
|
+
UNDEFINED_METHOD_ENTRY_P((def)->body.refined.orig_me))
|
209
|
+
|
210
|
+
void rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_visibility_t visi);
|
211
|
+
void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_visibility_t visi);
|
212
|
+
void rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi);
|
213
|
+
void rb_add_method_optimized(VALUE klass, ID mid, enum method_optimized_type, unsigned int index, rb_method_visibility_t visi);
|
214
|
+
void rb_add_refined_method_entry(VALUE refined_class, ID mid);
|
215
|
+
|
216
|
+
rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex);
|
217
|
+
rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, rb_method_definition_t *def);
|
218
|
+
|
219
|
+
const rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
|
220
|
+
|
221
|
+
const rb_method_entry_t *rb_method_entry(VALUE klass, ID id);
|
222
|
+
const rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class);
|
223
|
+
const rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
|
224
|
+
const rb_method_entry_t *rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
|
225
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
226
|
+
const rb_method_entry_t *rb_resolve_me_location(const rb_method_entry_t *, VALUE[5]);
|
227
|
+
RUBY_SYMBOL_EXPORT_END
|
228
|
+
|
229
|
+
const rb_callable_method_entry_t *rb_callable_method_entry(VALUE klass, ID id);
|
230
|
+
const rb_callable_method_entry_t *rb_callable_method_entry_or_negative(VALUE klass, ID id);
|
231
|
+
const rb_callable_method_entry_t *rb_callable_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class);
|
232
|
+
const rb_callable_method_entry_t *rb_callable_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
|
233
|
+
|
234
|
+
int rb_method_entry_arity(const rb_method_entry_t *me);
|
235
|
+
int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2);
|
236
|
+
st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me);
|
237
|
+
|
238
|
+
VALUE rb_method_entry_location(const rb_method_entry_t *me);
|
239
|
+
|
240
|
+
void rb_free_method_entry(const rb_method_entry_t *me);
|
241
|
+
|
242
|
+
const rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
|
243
|
+
const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class);
|
244
|
+
void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src);
|
245
|
+
|
246
|
+
void rb_method_table_insert(VALUE klass, struct rb_id_table *table, ID method_id, const rb_method_entry_t *me);
|
247
|
+
|
248
|
+
void rb_scope_visibility_set(rb_method_visibility_t);
|
249
|
+
|
250
|
+
VALUE rb_unnamed_parameters(int arity);
|
251
|
+
|
252
|
+
void rb_clear_method_cache(VALUE klass_or_module, ID mid);
|
253
|
+
void rb_clear_all_refinement_method_cache(void);
|
254
|
+
|
255
|
+
#endif /* RUBY_METHOD_H */
|