kanayago 0.2.0 → 0.4.0

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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +261 -0
  3. data/README.md +1 -1
  4. data/Rakefile +5 -48
  5. data/ext/kanayago/extconf.rb +8 -0
  6. data/ext/kanayago/kanayago.c +30 -185
  7. data/ext/kanayago/scope_node.c +2 -16
  8. data/ext/kanayago/variable_node.c +2 -1
  9. data/lib/kanayago/call_node.rb +19 -0
  10. data/lib/kanayago/constant_node.rb +15 -0
  11. data/lib/kanayago/literal_node.rb +4 -0
  12. data/lib/kanayago/scope_node.rb +14 -0
  13. data/lib/kanayago/statement_node.rb +16 -0
  14. data/lib/kanayago/variable_node.rb +4 -0
  15. data/lib/kanayago/version.rb +1 -1
  16. data/lib/kanayago.rb +3 -16
  17. data/script/setup_parser.rb +136 -0
  18. metadata +6 -64
  19. data/ext/kanayago/ccan/check_type/check_type.h +0 -63
  20. data/ext/kanayago/ccan/container_of/container_of.h +0 -142
  21. data/ext/kanayago/ccan/list/list.h +0 -791
  22. data/ext/kanayago/ccan/str/str.h +0 -17
  23. data/ext/kanayago/constant.h +0 -53
  24. data/ext/kanayago/id.h +0 -354
  25. data/ext/kanayago/id_table.h +0 -54
  26. data/ext/kanayago/include/ruby/st.h +0 -199
  27. data/ext/kanayago/internal/array.h +0 -154
  28. data/ext/kanayago/internal/basic_operators.h +0 -65
  29. data/ext/kanayago/internal/bignum.h +0 -245
  30. data/ext/kanayago/internal/bits.h +0 -650
  31. data/ext/kanayago/internal/compile.h +0 -34
  32. data/ext/kanayago/internal/compilers.h +0 -107
  33. data/ext/kanayago/internal/complex.h +0 -29
  34. data/ext/kanayago/internal/encoding.h +0 -39
  35. data/ext/kanayago/internal/error.h +0 -251
  36. data/ext/kanayago/internal/fixnum.h +0 -185
  37. data/ext/kanayago/internal/gc.h +0 -358
  38. data/ext/kanayago/internal/hash.h +0 -194
  39. data/ext/kanayago/internal/imemo.h +0 -322
  40. data/ext/kanayago/internal/io.h +0 -163
  41. data/ext/kanayago/internal/namespace.h +0 -81
  42. data/ext/kanayago/internal/numeric.h +0 -275
  43. data/ext/kanayago/internal/parse.h +0 -131
  44. data/ext/kanayago/internal/rational.h +0 -71
  45. data/ext/kanayago/internal/re.h +0 -33
  46. data/ext/kanayago/internal/ruby_parser.h +0 -125
  47. data/ext/kanayago/internal/sanitizers.h +0 -346
  48. data/ext/kanayago/internal/serial.h +0 -23
  49. data/ext/kanayago/internal/set_table.h +0 -70
  50. data/ext/kanayago/internal/static_assert.h +0 -16
  51. data/ext/kanayago/internal/string.h +0 -203
  52. data/ext/kanayago/internal/symbol.h +0 -46
  53. data/ext/kanayago/internal/thread.h +0 -112
  54. data/ext/kanayago/internal/variable.h +0 -74
  55. data/ext/kanayago/internal/vm.h +0 -136
  56. data/ext/kanayago/internal/warnings.h +0 -16
  57. data/ext/kanayago/internal.h +0 -105
  58. data/ext/kanayago/lex.c +0 -302
  59. data/ext/kanayago/method.h +0 -271
  60. data/ext/kanayago/node.c +0 -446
  61. data/ext/kanayago/node.h +0 -122
  62. data/ext/kanayago/node_name.inc +0 -224
  63. data/ext/kanayago/parse.c +0 -27377
  64. data/ext/kanayago/parse.h +0 -244
  65. data/ext/kanayago/parser_bits.h +0 -564
  66. data/ext/kanayago/parser_node.h +0 -32
  67. data/ext/kanayago/parser_st.c +0 -165
  68. data/ext/kanayago/parser_st.h +0 -162
  69. data/ext/kanayago/parser_value.h +0 -106
  70. data/ext/kanayago/probes.h +0 -4
  71. data/ext/kanayago/ruby_assert.h +0 -14
  72. data/ext/kanayago/ruby_atomic.h +0 -66
  73. data/ext/kanayago/ruby_parser.c +0 -1137
  74. data/ext/kanayago/rubyparser.h +0 -1394
  75. data/ext/kanayago/shape.h +0 -444
  76. data/ext/kanayago/st.c +0 -3223
  77. data/ext/kanayago/symbol.h +0 -116
  78. data/ext/kanayago/thread_pthread.h +0 -175
  79. data/ext/kanayago/universal_parser.c +0 -211
  80. data/ext/kanayago/vm_core.h +0 -2349
  81. data/ext/kanayago/vm_opts.h +0 -67
@@ -1,17 +0,0 @@
1
- /* CC0 (Public domain) - see ccan/licenses/CC0 file for details */
2
- #ifndef CCAN_STR_H
3
- #define CCAN_STR_H
4
- /**
5
- * ccan_stringify - Turn expression into a string literal
6
- * @expr: any C expression
7
- *
8
- * Example:
9
- * #define PRINT_COND_IF_FALSE(cond) \
10
- * ((cond) || printf("%s is false!", ccan_stringify(cond)))
11
- */
12
- #define stringify(expr) ccan_stringify_1(expr)
13
- #define ccan_stringify(expr) ccan_stringify_1(expr)
14
- /* Double-indirection required to stringify expansions */
15
- #define ccan_stringify_1(expr) #expr
16
-
17
- #endif /* CCAN_STR_H */
@@ -1,53 +0,0 @@
1
- #ifndef CONSTANT_H
2
- #define CONSTANT_H
3
- /**********************************************************************
4
-
5
- constant.h -
6
-
7
- $Author$
8
- created at: Sun Nov 15 00:09:33 2009
9
-
10
- Copyright (C) 2009 Yusuke Endoh
11
-
12
- **********************************************************************/
13
- #include "ruby/ruby.h"
14
- #include "id_table.h"
15
-
16
- typedef enum {
17
- CONST_DEPRECATED = 0x100,
18
-
19
- CONST_VISIBILITY_MASK = 0xff,
20
- CONST_PUBLIC = 0x00,
21
- CONST_PRIVATE,
22
- CONST_VISIBILITY_MAX
23
- } rb_const_flag_t;
24
-
25
- #define RB_CONST_PRIVATE_P(ce) \
26
- (((ce)->flag & CONST_VISIBILITY_MASK) == CONST_PRIVATE)
27
- #define RB_CONST_PUBLIC_P(ce) \
28
- (((ce)->flag & CONST_VISIBILITY_MASK) == CONST_PUBLIC)
29
-
30
- #define RB_CONST_DEPRECATED_P(ce) \
31
- ((ce)->flag & CONST_DEPRECATED)
32
-
33
- typedef struct rb_const_entry_struct {
34
- rb_const_flag_t flag;
35
- int line;
36
- VALUE value; /* should be mark */
37
- VALUE file; /* should be mark */
38
- } rb_const_entry_t;
39
-
40
- VALUE rb_mod_private_constant(int argc, const VALUE *argv, VALUE obj);
41
- VALUE rb_mod_public_constant(int argc, const VALUE *argv, VALUE obj);
42
- VALUE rb_mod_deprecate_constant(int argc, const VALUE *argv, VALUE obj);
43
- void rb_free_const_table(struct rb_id_table *tbl);
44
- VALUE rb_const_source_location(VALUE, ID);
45
-
46
- int rb_autoloading_value(VALUE mod, ID id, VALUE *value, rb_const_flag_t *flag);
47
- rb_const_entry_t *rb_const_lookup(VALUE klass, ID id);
48
- VALUE rb_public_const_get_at(VALUE klass, ID id);
49
- VALUE rb_public_const_get_from(VALUE klass, ID id);
50
- int rb_public_const_defined_from(VALUE klass, ID id);
51
- VALUE rb_const_source_location_at(VALUE, ID);
52
-
53
- #endif /* CONSTANT_H */
data/ext/kanayago/id.h DELETED
@@ -1,354 +0,0 @@
1
- /* DO NOT EDIT THIS FILE DIRECTLY: source is at template/id.h.tmpl */
2
- /**********************************************************************
3
-
4
- id.h -
5
-
6
- $Author$
7
- created at: Sun Oct 19 21:12:51 2008
8
-
9
- Copyright (C) 2007 Koichi Sasada
10
-
11
- **********************************************************************/
12
-
13
- #ifndef RUBY_ID_H
14
- #define RUBY_ID_H
15
-
16
- enum ruby_id_types {
17
- RUBY_ID_LOCAL = 0x00,
18
- RUBY_ID_STATIC_SYM = 0x01,
19
- RUBY_ID_INSTANCE = (0x01<<1),
20
- RUBY_ID_GLOBAL = (0x03<<1),
21
- RUBY_ID_ATTRSET = (0x04<<1),
22
- RUBY_ID_CONST = (0x05<<1),
23
- RUBY_ID_CLASS = (0x06<<1),
24
- RUBY_ID_INTERNAL = (0x07<<1),
25
- RUBY_ID_SCOPE_SHIFT = 4,
26
- RUBY_ID_SCOPE_MASK = (~(~0U<<(RUBY_ID_SCOPE_SHIFT-1))<<1)
27
- };
28
-
29
- #define ID_STATIC_SYM RUBY_ID_STATIC_SYM
30
- #define ID_SCOPE_SHIFT RUBY_ID_SCOPE_SHIFT
31
- #define ID_SCOPE_MASK RUBY_ID_SCOPE_MASK
32
- #define ID_LOCAL RUBY_ID_LOCAL
33
- #define ID_INSTANCE RUBY_ID_INSTANCE
34
- #define ID_GLOBAL RUBY_ID_GLOBAL
35
- #define ID_ATTRSET RUBY_ID_ATTRSET
36
- #define ID_CONST RUBY_ID_CONST
37
- #define ID_CLASS RUBY_ID_CLASS
38
- #define ID_INTERNAL RUBY_ID_INTERNAL
39
-
40
- #define symIFUNC ID2SYM(idIFUNC)
41
- #define symCFUNC ID2SYM(idCFUNC)
42
-
43
- #define RUBY_TOKEN_DOT2 128
44
- #define RUBY_TOKEN_DOT3 129
45
- #define RUBY_TOKEN_BDOT2 130
46
- #define RUBY_TOKEN_BDOT3 131
47
- #define RUBY_TOKEN_UPLUS 132
48
- #define RUBY_TOKEN_UMINUS 133
49
- #define RUBY_TOKEN_POW 134
50
- #define RUBY_TOKEN_CMP 135
51
- #define RUBY_TOKEN_LSHFT 136
52
- #define RUBY_TOKEN_RSHFT 137
53
- #define RUBY_TOKEN_LEQ 138
54
- #define RUBY_TOKEN_GEQ 139
55
- #define RUBY_TOKEN_EQ 140
56
- #define RUBY_TOKEN_EQQ 141
57
- #define RUBY_TOKEN_NEQ 142
58
- #define RUBY_TOKEN_MATCH 143
59
- #define RUBY_TOKEN_NMATCH 144
60
- #define RUBY_TOKEN_AREF 145
61
- #define RUBY_TOKEN_ASET 146
62
- #define RUBY_TOKEN_COLON2 147
63
- #define RUBY_TOKEN_ANDOP 148
64
- #define RUBY_TOKEN_OROP 149
65
- #define RUBY_TOKEN_ANDDOT 150
66
- #define RUBY_TOKEN(t) RUBY_TOKEN_##t
67
-
68
- #define RUBY_TOKEN2ID_TYPE(tok, type) ((tok<<RUBY_ID_SCOPE_SHIFT)|type|RUBY_ID_STATIC_SYM)
69
- #define TOKEN2LOCALID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_LOCAL)
70
- #define TOKEN2INSTANCEID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_INSTANCE)
71
- #define TOKEN2GLOBALID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_GLOBAL)
72
- #define TOKEN2CONSTID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_CONST)
73
- #define TOKEN2CLASSID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_CLASS)
74
- #define TOKEN2ATTRSETID(tok) RUBY_TOKEN2ID_TYPE(tok, RUBY_ID_ATTRSET)
75
-
76
- enum ruby_method_ids {
77
- idDot2 = RUBY_TOKEN(DOT2),
78
- idDot3 = RUBY_TOKEN(DOT3),
79
- idUPlus = RUBY_TOKEN(UPLUS),
80
- idUMinus = RUBY_TOKEN(UMINUS),
81
- idPow = RUBY_TOKEN(POW),
82
- idCmp = RUBY_TOKEN(CMP),
83
- idPLUS = '+',
84
- idMINUS = '-',
85
- idMULT = '*',
86
- idDIV = '/',
87
- idMOD = '%',
88
- idLTLT = RUBY_TOKEN(LSHFT),
89
- idGTGT = RUBY_TOKEN(RSHFT),
90
- idLT = '<',
91
- idLE = RUBY_TOKEN(LEQ),
92
- idGT = '>',
93
- idGE = RUBY_TOKEN(GEQ),
94
- idEq = RUBY_TOKEN(EQ),
95
- idEqq = RUBY_TOKEN(EQQ),
96
- idNeq = RUBY_TOKEN(NEQ),
97
- idNot = '!',
98
- idAnd = '&',
99
- idOr = '|',
100
- idBackquote = '`',
101
- idEqTilde = RUBY_TOKEN(MATCH),
102
- idNeqTilde = RUBY_TOKEN(NMATCH),
103
- idAREF = RUBY_TOKEN(AREF),
104
- idASET = RUBY_TOKEN(ASET),
105
- idCOLON2 = RUBY_TOKEN(COLON2),
106
- idANDOP = RUBY_TOKEN(ANDOP),
107
- idOROP = RUBY_TOKEN(OROP),
108
- idANDDOT = RUBY_TOKEN(ANDDOT),
109
- tPRESERVED_ID_BEGIN = 150,
110
- idNilP,
111
- idIncludeP,
112
- idNULL,
113
- idEmptyP,
114
- idEqlP,
115
- idRespond_to,
116
- idRespond_to_missing,
117
- idIFUNC,
118
- idCFUNC,
119
- id_core_set_method_alias,
120
- id_core_set_variable_alias,
121
- id_core_undef_method,
122
- id_core_define_method,
123
- id_core_define_singleton_method,
124
- id_core_set_postexe,
125
- id_core_hash_merge_ptr,
126
- id_core_hash_merge_kwd,
127
- id_core_raise,
128
- id_core_sprintf,
129
- id_debug_created_info,
130
- tPRESERVED_ID_END,
131
-
132
- /* LOCAL tokens {{{ */
133
- tTOKEN_LOCAL_BEGIN = tPRESERVED_ID_END-1,
134
- tMax,
135
- tMin,
136
- tHash,
137
- tFreeze,
138
- tInspect,
139
- tIntern,
140
- tObject_id,
141
- t__id__,
142
- tConst_added,
143
- tConst_missing,
144
- tMethodMissing,
145
- tMethod_added,
146
- tSingleton_method_added,
147
- tMethod_removed,
148
- tSingleton_method_removed,
149
- tMethod_undefined,
150
- tSingleton_method_undefined,
151
- tLength,
152
- tSize,
153
- tGets,
154
- tSucc,
155
- tEach,
156
- tProc,
157
- tLambda,
158
- tSend,
159
- t__send__,
160
- t__recursive_key__,
161
- tInitialize,
162
- tInitialize_copy,
163
- tInitialize_clone,
164
- tInitialize_dup,
165
- tTo_int,
166
- tTo_ary,
167
- tTo_str,
168
- tTo_sym,
169
- tTo_hash,
170
- tTo_proc,
171
- tTo_io,
172
- tTo_a,
173
- tTo_s,
174
- tTo_i,
175
- tTo_f,
176
- tTo_r,
177
- tBt,
178
- tBt_locations,
179
- tCall,
180
- tMesg,
181
- tException,
182
- tLocals,
183
- tNOT,
184
- tAND,
185
- tOR,
186
- tDiv,
187
- tDivmod,
188
- tFdiv,
189
- tQuo,
190
- tName,
191
- tNil,
192
- tPath,
193
- tPack,
194
- tBuffer,
195
- tAborted,
196
- tExited,
197
- tUScore,
198
- tNUMPARAM_1,
199
- tNUMPARAM_2,
200
- tNUMPARAM_3,
201
- tNUMPARAM_4,
202
- tNUMPARAM_5,
203
- tNUMPARAM_6,
204
- tNUMPARAM_7,
205
- tNUMPARAM_8,
206
- tNUMPARAM_9,
207
- tDefault,
208
- tTOKEN_LOCAL_END,
209
- /* LOCAL tokens }}} */
210
-
211
- /* INSTANCE tokens {{{ */
212
- tTOKEN_INSTANCE_BEGIN = tTOKEN_LOCAL_END-1,
213
- tTOKEN_INSTANCE_END,
214
- /* INSTANCE tokens }}} */
215
-
216
- /* GLOBAL tokens {{{ */
217
- tTOKEN_GLOBAL_BEGIN = tTOKEN_INSTANCE_END-1,
218
- tLASTLINE,
219
- tBACKREF,
220
- tERROR_INFO,
221
- tTOKEN_GLOBAL_END,
222
- /* GLOBAL tokens }}} */
223
-
224
- /* CONST tokens {{{ */
225
- tTOKEN_CONST_BEGIN = tTOKEN_GLOBAL_END-1,
226
- tRuby,
227
- tTOKEN_CONST_END,
228
- /* CONST tokens }}} */
229
-
230
- /* CLASS tokens {{{ */
231
- tTOKEN_CLASS_BEGIN = tTOKEN_CONST_END-1,
232
- tTOKEN_CLASS_END,
233
- /* CLASS tokens }}} */
234
-
235
- /* ATTRSET tokens {{{ */
236
- tTOKEN_ATTRSET_BEGIN = tTOKEN_CLASS_END-1,
237
- tTOKEN_ATTRSET_END,
238
- /* ATTRSET tokens }}} */
239
-
240
- tNEXT_ID = tTOKEN_ATTRSET_END,
241
-
242
- /* LOCAL IDs {{{ */
243
- #define DEFINE_LOCALID_FROM_TOKEN(n) id##n = TOKEN2LOCALID(t##n)
244
- DEFINE_LOCALID_FROM_TOKEN(Max),
245
- DEFINE_LOCALID_FROM_TOKEN(Min),
246
- DEFINE_LOCALID_FROM_TOKEN(Hash),
247
- DEFINE_LOCALID_FROM_TOKEN(Freeze),
248
- DEFINE_LOCALID_FROM_TOKEN(Inspect),
249
- DEFINE_LOCALID_FROM_TOKEN(Intern),
250
- DEFINE_LOCALID_FROM_TOKEN(Object_id),
251
- DEFINE_LOCALID_FROM_TOKEN(__id__),
252
- DEFINE_LOCALID_FROM_TOKEN(Const_added),
253
- DEFINE_LOCALID_FROM_TOKEN(Const_missing),
254
- DEFINE_LOCALID_FROM_TOKEN(MethodMissing),
255
- DEFINE_LOCALID_FROM_TOKEN(Method_added),
256
- DEFINE_LOCALID_FROM_TOKEN(Singleton_method_added),
257
- DEFINE_LOCALID_FROM_TOKEN(Method_removed),
258
- DEFINE_LOCALID_FROM_TOKEN(Singleton_method_removed),
259
- DEFINE_LOCALID_FROM_TOKEN(Method_undefined),
260
- DEFINE_LOCALID_FROM_TOKEN(Singleton_method_undefined),
261
- DEFINE_LOCALID_FROM_TOKEN(Length),
262
- DEFINE_LOCALID_FROM_TOKEN(Size),
263
- DEFINE_LOCALID_FROM_TOKEN(Gets),
264
- DEFINE_LOCALID_FROM_TOKEN(Succ),
265
- DEFINE_LOCALID_FROM_TOKEN(Each),
266
- DEFINE_LOCALID_FROM_TOKEN(Proc),
267
- DEFINE_LOCALID_FROM_TOKEN(Lambda),
268
- DEFINE_LOCALID_FROM_TOKEN(Send),
269
- DEFINE_LOCALID_FROM_TOKEN(__send__),
270
- DEFINE_LOCALID_FROM_TOKEN(__recursive_key__),
271
- DEFINE_LOCALID_FROM_TOKEN(Initialize),
272
- DEFINE_LOCALID_FROM_TOKEN(Initialize_copy),
273
- DEFINE_LOCALID_FROM_TOKEN(Initialize_clone),
274
- DEFINE_LOCALID_FROM_TOKEN(Initialize_dup),
275
- DEFINE_LOCALID_FROM_TOKEN(To_int),
276
- DEFINE_LOCALID_FROM_TOKEN(To_ary),
277
- DEFINE_LOCALID_FROM_TOKEN(To_str),
278
- DEFINE_LOCALID_FROM_TOKEN(To_sym),
279
- DEFINE_LOCALID_FROM_TOKEN(To_hash),
280
- DEFINE_LOCALID_FROM_TOKEN(To_proc),
281
- DEFINE_LOCALID_FROM_TOKEN(To_io),
282
- DEFINE_LOCALID_FROM_TOKEN(To_a),
283
- DEFINE_LOCALID_FROM_TOKEN(To_s),
284
- DEFINE_LOCALID_FROM_TOKEN(To_i),
285
- DEFINE_LOCALID_FROM_TOKEN(To_f),
286
- DEFINE_LOCALID_FROM_TOKEN(To_r),
287
- DEFINE_LOCALID_FROM_TOKEN(Bt),
288
- DEFINE_LOCALID_FROM_TOKEN(Bt_locations),
289
- DEFINE_LOCALID_FROM_TOKEN(Call),
290
- DEFINE_LOCALID_FROM_TOKEN(Mesg),
291
- DEFINE_LOCALID_FROM_TOKEN(Exception),
292
- DEFINE_LOCALID_FROM_TOKEN(Locals),
293
- DEFINE_LOCALID_FROM_TOKEN(NOT),
294
- DEFINE_LOCALID_FROM_TOKEN(AND),
295
- DEFINE_LOCALID_FROM_TOKEN(OR),
296
- DEFINE_LOCALID_FROM_TOKEN(Div),
297
- DEFINE_LOCALID_FROM_TOKEN(Divmod),
298
- DEFINE_LOCALID_FROM_TOKEN(Fdiv),
299
- DEFINE_LOCALID_FROM_TOKEN(Quo),
300
- DEFINE_LOCALID_FROM_TOKEN(Name),
301
- DEFINE_LOCALID_FROM_TOKEN(Nil),
302
- DEFINE_LOCALID_FROM_TOKEN(Path),
303
- DEFINE_LOCALID_FROM_TOKEN(Pack),
304
- DEFINE_LOCALID_FROM_TOKEN(Buffer),
305
- DEFINE_LOCALID_FROM_TOKEN(Aborted),
306
- DEFINE_LOCALID_FROM_TOKEN(Exited),
307
- DEFINE_LOCALID_FROM_TOKEN(UScore),
308
- DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_1),
309
- DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_2),
310
- DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_3),
311
- DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_4),
312
- DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_5),
313
- DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_6),
314
- DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_7),
315
- DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_8),
316
- DEFINE_LOCALID_FROM_TOKEN(NUMPARAM_9),
317
- DEFINE_LOCALID_FROM_TOKEN(Default),
318
- #undef DEFINE_LOCALID_FROM_TOKEN
319
- /* LOCAL IDs }}} */
320
-
321
- /* INSTANCE IDs {{{ */
322
- #define DEFINE_INSTANCEID_FROM_TOKEN(n) id##n = TOKEN2INSTANCEID(t##n)
323
- #undef DEFINE_INSTANCEID_FROM_TOKEN
324
- /* INSTANCE IDs }}} */
325
-
326
- /* GLOBAL IDs {{{ */
327
- #define DEFINE_GLOBALID_FROM_TOKEN(n) id##n = TOKEN2GLOBALID(t##n)
328
- DEFINE_GLOBALID_FROM_TOKEN(LASTLINE),
329
- DEFINE_GLOBALID_FROM_TOKEN(BACKREF),
330
- DEFINE_GLOBALID_FROM_TOKEN(ERROR_INFO),
331
- #undef DEFINE_GLOBALID_FROM_TOKEN
332
- /* GLOBAL IDs }}} */
333
-
334
- /* CONST IDs {{{ */
335
- #define DEFINE_CONSTID_FROM_TOKEN(n) id##n = TOKEN2CONSTID(t##n)
336
- DEFINE_CONSTID_FROM_TOKEN(Ruby),
337
- #undef DEFINE_CONSTID_FROM_TOKEN
338
- /* CONST IDs }}} */
339
-
340
- /* CLASS IDs {{{ */
341
- #define DEFINE_CLASSID_FROM_TOKEN(n) id##n = TOKEN2CLASSID(t##n)
342
- #undef DEFINE_CLASSID_FROM_TOKEN
343
- /* CLASS IDs }}} */
344
-
345
- /* ATTRSET IDs {{{ */
346
- #define DEFINE_ATTRSETID_FROM_TOKEN(n) id##n = TOKEN2ATTRSETID(t##n)
347
- #undef DEFINE_ATTRSETID_FROM_TOKEN
348
- /* ATTRSET IDs }}} */
349
-
350
- tLAST_OP_ID = tPRESERVED_ID_END-1,
351
- idLAST_OP_ID = tLAST_OP_ID >> ID_SCOPE_SHIFT
352
- };
353
-
354
- #endif /* RUBY_ID_H */
@@ -1,54 +0,0 @@
1
- #ifndef RUBY_ID_TABLE_H
2
- #define RUBY_ID_TABLE_H 1
3
- #include "ruby/internal/config.h"
4
- #include <stddef.h>
5
- #include "ruby/ruby.h"
6
-
7
- struct rb_id_table;
8
-
9
- /* compatible with ST_* */
10
- enum rb_id_table_iterator_result {
11
- ID_TABLE_CONTINUE = ST_CONTINUE,
12
- ID_TABLE_STOP = ST_STOP,
13
- ID_TABLE_DELETE = ST_DELETE,
14
- ID_TABLE_REPLACE = ST_REPLACE,
15
- ID_TABLE_ITERATOR_RESULT_END
16
- };
17
-
18
- struct rb_id_table *rb_id_table_create(size_t size);
19
- struct rb_id_table *rb_id_table_init(struct rb_id_table *tbl, size_t capa);
20
-
21
- void rb_id_table_free(struct rb_id_table *tbl);
22
- void rb_id_table_free_items(struct rb_id_table *tbl);
23
- void rb_id_table_clear(struct rb_id_table *tbl);
24
-
25
- size_t rb_id_table_memsize(const struct rb_id_table *tbl);
26
-
27
- int rb_id_table_insert(struct rb_id_table *tbl, ID id, VALUE val);
28
- int rb_id_table_lookup(struct rb_id_table *tbl, ID id, VALUE *valp);
29
- int rb_id_table_delete(struct rb_id_table *tbl, ID id);
30
-
31
- typedef enum rb_id_table_iterator_result rb_id_table_update_value_callback_func_t(VALUE *val, void *data, int existing);
32
- typedef enum rb_id_table_iterator_result rb_id_table_foreach_func_t(ID id, VALUE val, void *data);
33
- typedef enum rb_id_table_iterator_result rb_id_table_foreach_values_func_t(VALUE val, void *data);
34
- void rb_id_table_foreach(struct rb_id_table *tbl, rb_id_table_foreach_func_t *func, void *data);
35
- void rb_id_table_foreach_values(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, void *data);
36
- void rb_id_table_foreach_values_with_replace(struct rb_id_table *tbl, rb_id_table_foreach_values_func_t *func, rb_id_table_update_value_callback_func_t *replace, void *data);
37
-
38
- VALUE rb_managed_id_table_create(const rb_data_type_t *type, size_t capa);
39
- VALUE rb_managed_id_table_new(size_t capa);
40
- VALUE rb_managed_id_table_dup(VALUE table);
41
- int rb_managed_id_table_insert(VALUE table, ID id, VALUE val);
42
- int rb_managed_id_table_lookup(VALUE table, ID id, VALUE *valp);
43
- size_t rb_managed_id_table_size(VALUE table);
44
- void rb_managed_id_table_foreach(VALUE table, rb_id_table_foreach_func_t *func, void *data);
45
- void rb_managed_id_table_foreach_values(VALUE table, rb_id_table_foreach_values_func_t *func, void *data);
46
- int rb_managed_id_table_delete(VALUE table, ID id);
47
-
48
- extern const rb_data_type_t rb_managed_id_table_type;
49
-
50
- RUBY_SYMBOL_EXPORT_BEGIN
51
- size_t rb_id_table_size(const struct rb_id_table *tbl);
52
- RUBY_SYMBOL_EXPORT_END
53
-
54
- #endif /* RUBY_ID_TABLE_H */
@@ -1,199 +0,0 @@
1
- /* This is a public domain general purpose hash table package
2
- originally written by Peter Moore @ UCB.
3
-
4
- The hash table data structures were redesigned and the package was
5
- rewritten by Vladimir Makarov <vmakarov@redhat.com>. */
6
-
7
- #ifndef RUBY_ST_H
8
- #define RUBY_ST_H 1
9
-
10
- #if defined(__cplusplus)
11
- extern "C" {
12
- #if 0
13
- } /* satisfy cc-mode */
14
- #endif
15
- #endif
16
-
17
- #include "ruby/defines.h"
18
-
19
- RUBY_SYMBOL_EXPORT_BEGIN
20
-
21
- #if SIZEOF_LONG == SIZEOF_VOIDP
22
- typedef unsigned long st_data_t;
23
- #elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
24
- typedef unsigned LONG_LONG st_data_t;
25
- #else
26
- # error ---->> st.c requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
27
- #endif
28
- #define ST_DATA_T_DEFINED
29
-
30
- #ifndef CHAR_BIT
31
- # ifdef HAVE_LIMITS_H
32
- # include <limits.h>
33
- # else
34
- # define CHAR_BIT 8
35
- # endif
36
- #endif
37
- #ifndef _
38
- # define _(args) args
39
- #endif
40
- #ifndef ANYARGS
41
- # ifdef __cplusplus
42
- # define ANYARGS ...
43
- # else
44
- # define ANYARGS
45
- # endif
46
- #endif
47
-
48
- typedef struct st_table st_table;
49
-
50
- typedef st_data_t st_index_t;
51
-
52
- /* Maximal value of unsigned integer type st_index_t. */
53
- #define MAX_ST_INDEX_VAL (~(st_index_t) 0)
54
-
55
- typedef int st_compare_func(st_data_t, st_data_t);
56
- typedef st_index_t st_hash_func(st_data_t);
57
-
58
- typedef char st_check_for_sizeof_st_index_t[SIZEOF_VOIDP == (int)sizeof(st_index_t) ? 1 : -1];
59
- #define SIZEOF_ST_INDEX_T SIZEOF_VOIDP
60
-
61
- struct st_hash_type {
62
- int (*compare)(st_data_t, st_data_t); /* st_compare_func* */
63
- st_index_t (*hash)(st_data_t); /* st_hash_func* */
64
- };
65
-
66
- #define ST_INDEX_BITS (SIZEOF_ST_INDEX_T * CHAR_BIT)
67
-
68
- #if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR) && defined(HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P)
69
- # define ST_DATA_COMPATIBLE_P(type) \
70
- __builtin_choose_expr(__builtin_types_compatible_p(type, st_data_t), 1, 0)
71
- #else
72
- # define ST_DATA_COMPATIBLE_P(type) 0
73
- #endif
74
-
75
- typedef struct st_table_entry st_table_entry;
76
-
77
- struct st_table_entry; /* defined in st.c */
78
-
79
- struct st_table {
80
- /* Cached features of the table -- see st.c for more details. */
81
- unsigned char entry_power, bin_power, size_ind;
82
- /* How many times the table was rebuilt. */
83
- unsigned int rebuilds_num;
84
- const struct st_hash_type *type;
85
- /* Number of entries currently in the table. */
86
- st_index_t num_entries;
87
- /* Array of bins used for access by keys. */
88
- st_index_t *bins;
89
- /* Start and bound index of entries in array entries.
90
- entries_starts and entries_bound are in interval
91
- [0,allocated_entries]. */
92
- st_index_t entries_start, entries_bound;
93
- /* Array of size 2^entry_power. */
94
- st_table_entry *entries;
95
- };
96
-
97
- #define st_is_member(table,key) st_lookup((table),(key),(st_data_t *)0)
98
-
99
- enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK, ST_REPLACE};
100
-
101
- size_t rb_st_table_size(const struct st_table *tbl);
102
- #define st_table_size rb_st_table_size
103
- st_table *rb_st_init_table(const struct st_hash_type *);
104
- #define st_init_table rb_st_init_table
105
- st_table *rb_st_init_table_with_size(const struct st_hash_type *, st_index_t);
106
- #define st_init_table_with_size rb_st_init_table_with_size
107
- st_table *rb_st_init_numtable(void);
108
- #define st_init_numtable rb_st_init_numtable
109
- st_table *rb_st_init_numtable_with_size(st_index_t);
110
- #define st_init_numtable_with_size rb_st_init_numtable_with_size
111
- st_table *rb_st_init_strtable(void);
112
- #define st_init_strtable rb_st_init_strtable
113
- st_table *rb_st_init_strtable_with_size(st_index_t);
114
- #define st_init_strtable_with_size rb_st_init_strtable_with_size
115
- st_table *rb_st_init_strcasetable(void);
116
- #define st_init_strcasetable rb_st_init_strcasetable
117
- st_table *rb_st_init_strcasetable_with_size(st_index_t);
118
- #define st_init_strcasetable_with_size rb_st_init_strcasetable_with_size
119
- int rb_st_delete(st_table *, st_data_t *, st_data_t *); /* returns 0:notfound 1:deleted */
120
- #define st_delete rb_st_delete
121
- int rb_st_delete_safe(st_table *, st_data_t *, st_data_t *, st_data_t);
122
- #define st_delete_safe rb_st_delete_safe
123
- int rb_st_shift(st_table *, st_data_t *, st_data_t *); /* returns 0:notfound 1:deleted */
124
- #define st_shift rb_st_shift
125
- int rb_st_insert(st_table *, st_data_t, st_data_t);
126
- #define st_insert rb_st_insert
127
- int rb_st_insert2(st_table *, st_data_t, st_data_t, st_data_t (*)(st_data_t));
128
- #define st_insert2 rb_st_insert2
129
- int rb_st_lookup(st_table *, st_data_t, st_data_t *);
130
- #define st_lookup rb_st_lookup
131
- int rb_st_get_key(st_table *, st_data_t, st_data_t *);
132
- #define st_get_key rb_st_get_key
133
- typedef int st_update_callback_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing);
134
- /* *key may be altered, but must equal to the old key, i.e., the
135
- * results of hash() are same and compare() returns 0, otherwise the
136
- * behavior is undefined */
137
- int rb_st_update(st_table *table, st_data_t key, st_update_callback_func *func, st_data_t arg);
138
- #define st_update rb_st_update
139
- typedef int st_foreach_callback_func(st_data_t, st_data_t, st_data_t);
140
- typedef int st_foreach_check_callback_func(st_data_t, st_data_t, st_data_t, int);
141
- int rb_st_foreach_with_replace(st_table *tab, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg);
142
- #define st_foreach_with_replace rb_st_foreach_with_replace
143
- int rb_st_foreach(st_table *, st_foreach_callback_func *, st_data_t);
144
- #define st_foreach rb_st_foreach
145
- int rb_st_foreach_check(st_table *, st_foreach_check_callback_func *, st_data_t, st_data_t);
146
- #define st_foreach_check rb_st_foreach_check
147
- st_index_t rb_st_keys(st_table *table, st_data_t *keys, st_index_t size);
148
- #define st_keys rb_st_keys
149
- st_index_t rb_st_keys_check(st_table *table, st_data_t *keys, st_index_t size, st_data_t never);
150
- #define st_keys_check rb_st_keys_check
151
- st_index_t rb_st_values(st_table *table, st_data_t *values, st_index_t size);
152
- #define st_values rb_st_values
153
- st_index_t rb_st_values_check(st_table *table, st_data_t *values, st_index_t size, st_data_t never);
154
- #define st_values_check rb_st_values_check
155
- void rb_st_add_direct(st_table *, st_data_t, st_data_t);
156
- #define st_add_direct rb_st_add_direct
157
- void rb_st_free_table(st_table *);
158
- #define st_free_table rb_st_free_table
159
- void rb_st_cleanup_safe(st_table *, st_data_t);
160
- #define st_cleanup_safe rb_st_cleanup_safe
161
- void rb_st_clear(st_table *);
162
- #define st_clear rb_st_clear
163
- st_table *rb_st_copy(st_table *);
164
- #define st_copy rb_st_copy
165
- CONSTFUNC(int rb_st_numcmp(st_data_t, st_data_t));
166
- #define st_numcmp rb_st_numcmp
167
- CONSTFUNC(st_index_t rb_st_numhash(st_data_t));
168
- #define st_numhash rb_st_numhash
169
- PUREFUNC(int rb_st_locale_insensitive_strcasecmp(const char *s1, const char *s2));
170
- #define st_locale_insensitive_strcasecmp rb_st_locale_insensitive_strcasecmp
171
- PUREFUNC(int rb_st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n));
172
- #define st_locale_insensitive_strncasecmp rb_st_locale_insensitive_strncasecmp
173
- #define st_strcasecmp rb_st_locale_insensitive_strcasecmp
174
- #define st_strncasecmp rb_st_locale_insensitive_strncasecmp
175
- PUREFUNC(size_t rb_st_memsize(const st_table *));
176
- #define st_memsize rb_st_memsize
177
- PUREFUNC(st_index_t rb_st_hash(const void *ptr, size_t len, st_index_t h));
178
- #define st_hash rb_st_hash
179
- CONSTFUNC(st_index_t rb_st_hash_uint32(st_index_t h, uint32_t i));
180
- #define st_hash_uint32 rb_st_hash_uint32
181
- CONSTFUNC(st_index_t rb_st_hash_uint(st_index_t h, st_index_t i));
182
- #define st_hash_uint rb_st_hash_uint
183
- CONSTFUNC(st_index_t rb_st_hash_end(st_index_t h));
184
- #define st_hash_end rb_st_hash_end
185
- CONSTFUNC(st_index_t rb_st_hash_start(st_index_t h));
186
- #define st_hash_start(h) ((st_index_t)(h))
187
-
188
- void rb_hash_bulk_insert_into_st_table(long, const VALUE *, VALUE);
189
-
190
- RUBY_SYMBOL_EXPORT_END
191
-
192
- #if defined(__cplusplus)
193
- #if 0
194
- { /* satisfy cc-mode */
195
- #endif
196
- } /* extern "C" { */
197
- #endif
198
-
199
- #endif /* RUBY_ST_H */