sender 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/ext/sender/node.h ADDED
@@ -0,0 +1,516 @@
1
+ /**********************************************************************
2
+
3
+ node.h -
4
+
5
+ $Author: yugui $
6
+ created at: Fri May 28 15:14:02 JST 1993
7
+
8
+ Copyright (C) 1993-2007 Yukihiro Matsumoto
9
+
10
+ **********************************************************************/
11
+
12
+ #ifndef RUBY_NODE_H
13
+ #define RUBY_NODE_H 1
14
+
15
+ #if defined(__cplusplus)
16
+ extern "C" {
17
+ #if 0
18
+ } /* satisfy cc-mode */
19
+ #endif
20
+ #endif
21
+
22
+ enum node_type {
23
+ NODE_METHOD,
24
+ #define NODE_METHOD NODE_METHOD
25
+ NODE_FBODY,
26
+ #define NODE_FBODY NODE_FBODY
27
+ NODE_CFUNC,
28
+ #define NODE_CFUNC NODE_CFUNC
29
+ NODE_SCOPE,
30
+ #define NODE_SCOPE NODE_SCOPE
31
+ NODE_BLOCK,
32
+ #define NODE_BLOCK NODE_BLOCK
33
+ NODE_IF,
34
+ #define NODE_IF NODE_IF
35
+ NODE_CASE,
36
+ #define NODE_CASE NODE_CASE
37
+ NODE_WHEN,
38
+ #define NODE_WHEN NODE_WHEN
39
+ NODE_OPT_N,
40
+ #define NODE_OPT_N NODE_OPT_N
41
+ NODE_WHILE,
42
+ #define NODE_WHILE NODE_WHILE
43
+ NODE_UNTIL,
44
+ #define NODE_UNTIL NODE_UNTIL
45
+ NODE_ITER,
46
+ #define NODE_ITER NODE_ITER
47
+ NODE_FOR,
48
+ #define NODE_FOR NODE_FOR
49
+ NODE_BREAK,
50
+ #define NODE_BREAK NODE_BREAK
51
+ NODE_NEXT,
52
+ #define NODE_NEXT NODE_NEXT
53
+ NODE_REDO,
54
+ #define NODE_REDO NODE_REDO
55
+ NODE_RETRY,
56
+ #define NODE_RETRY NODE_RETRY
57
+ NODE_BEGIN,
58
+ #define NODE_BEGIN NODE_BEGIN
59
+ NODE_RESCUE,
60
+ #define NODE_RESCUE NODE_RESCUE
61
+ NODE_RESBODY,
62
+ #define NODE_RESBODY NODE_RESBODY
63
+ NODE_ENSURE,
64
+ #define NODE_ENSURE NODE_ENSURE
65
+ NODE_AND,
66
+ #define NODE_AND NODE_AND
67
+ NODE_OR,
68
+ #define NODE_OR NODE_OR
69
+ NODE_MASGN,
70
+ #define NODE_MASGN NODE_MASGN
71
+ NODE_LASGN,
72
+ #define NODE_LASGN NODE_LASGN
73
+ NODE_DASGN,
74
+ #define NODE_DASGN NODE_DASGN
75
+ NODE_DASGN_CURR,
76
+ #define NODE_DASGN_CURR NODE_DASGN_CURR
77
+ NODE_GASGN,
78
+ #define NODE_GASGN NODE_GASGN
79
+ NODE_IASGN,
80
+ #define NODE_IASGN NODE_IASGN
81
+ NODE_IASGN2,
82
+ #define NODE_IASGN2 NODE_IASGN2
83
+ NODE_CDECL,
84
+ #define NODE_CDECL NODE_CDECL
85
+ NODE_CVASGN,
86
+ #define NODE_CVASGN NODE_CVASGN
87
+ NODE_CVDECL,
88
+ #define NODE_CVDECL NODE_CVDECL
89
+ NODE_OP_ASGN1,
90
+ #define NODE_OP_ASGN1 NODE_OP_ASGN1
91
+ NODE_OP_ASGN2,
92
+ #define NODE_OP_ASGN2 NODE_OP_ASGN2
93
+ NODE_OP_ASGN_AND,
94
+ #define NODE_OP_ASGN_AND NODE_OP_ASGN_AND
95
+ NODE_OP_ASGN_OR,
96
+ #define NODE_OP_ASGN_OR NODE_OP_ASGN_OR
97
+ NODE_CALL,
98
+ #define NODE_CALL NODE_CALL
99
+ NODE_FCALL,
100
+ #define NODE_FCALL NODE_FCALL
101
+ NODE_VCALL,
102
+ #define NODE_VCALL NODE_VCALL
103
+ NODE_SUPER,
104
+ #define NODE_SUPER NODE_SUPER
105
+ NODE_ZSUPER,
106
+ #define NODE_ZSUPER NODE_ZSUPER
107
+ NODE_ARRAY,
108
+ #define NODE_ARRAY NODE_ARRAY
109
+ NODE_ZARRAY,
110
+ #define NODE_ZARRAY NODE_ZARRAY
111
+ NODE_VALUES,
112
+ #define NODE_VALUES NODE_VALUES
113
+ NODE_HASH,
114
+ #define NODE_HASH NODE_HASH
115
+ NODE_RETURN,
116
+ #define NODE_RETURN NODE_RETURN
117
+ NODE_YIELD,
118
+ #define NODE_YIELD NODE_YIELD
119
+ NODE_LVAR,
120
+ #define NODE_LVAR NODE_LVAR
121
+ NODE_DVAR,
122
+ #define NODE_DVAR NODE_DVAR
123
+ NODE_GVAR,
124
+ #define NODE_GVAR NODE_GVAR
125
+ NODE_IVAR,
126
+ #define NODE_IVAR NODE_IVAR
127
+ NODE_CONST,
128
+ #define NODE_CONST NODE_CONST
129
+ NODE_CVAR,
130
+ #define NODE_CVAR NODE_CVAR
131
+ NODE_NTH_REF,
132
+ #define NODE_NTH_REF NODE_NTH_REF
133
+ NODE_BACK_REF,
134
+ #define NODE_BACK_REF NODE_BACK_REF
135
+ NODE_MATCH,
136
+ #define NODE_MATCH NODE_MATCH
137
+ NODE_MATCH2,
138
+ #define NODE_MATCH2 NODE_MATCH2
139
+ NODE_MATCH3,
140
+ #define NODE_MATCH3 NODE_MATCH3
141
+ NODE_LIT,
142
+ #define NODE_LIT NODE_LIT
143
+ NODE_STR,
144
+ #define NODE_STR NODE_STR
145
+ NODE_DSTR,
146
+ #define NODE_DSTR NODE_DSTR
147
+ NODE_XSTR,
148
+ #define NODE_XSTR NODE_XSTR
149
+ NODE_DXSTR,
150
+ #define NODE_DXSTR NODE_DXSTR
151
+ NODE_EVSTR,
152
+ #define NODE_EVSTR NODE_EVSTR
153
+ NODE_DREGX,
154
+ #define NODE_DREGX NODE_DREGX
155
+ NODE_DREGX_ONCE,
156
+ #define NODE_DREGX_ONCE NODE_DREGX_ONCE
157
+ NODE_ARGS,
158
+ #define NODE_ARGS NODE_ARGS
159
+ NODE_ARGS_AUX,
160
+ #define NODE_ARGS_AUX NODE_ARGS_AUX
161
+ NODE_OPT_ARG,
162
+ #define NODE_OPT_ARG NODE_OPT_ARG
163
+ NODE_POSTARG,
164
+ #define NODE_POSTARG NODE_POSTARG
165
+ NODE_ARGSCAT,
166
+ #define NODE_ARGSCAT NODE_ARGSCAT
167
+ NODE_ARGSPUSH,
168
+ #define NODE_ARGSPUSH NODE_ARGSPUSH
169
+ NODE_SPLAT,
170
+ #define NODE_SPLAT NODE_SPLAT
171
+ NODE_TO_ARY,
172
+ #define NODE_TO_ARY NODE_TO_ARY
173
+ NODE_BLOCK_ARG,
174
+ #define NODE_BLOCK_ARG NODE_BLOCK_ARG
175
+ NODE_BLOCK_PASS,
176
+ #define NODE_BLOCK_PASS NODE_BLOCK_PASS
177
+ NODE_DEFN,
178
+ #define NODE_DEFN NODE_DEFN
179
+ NODE_DEFS,
180
+ #define NODE_DEFS NODE_DEFS
181
+ NODE_ALIAS,
182
+ #define NODE_ALIAS NODE_ALIAS
183
+ NODE_VALIAS,
184
+ #define NODE_VALIAS NODE_VALIAS
185
+ NODE_UNDEF,
186
+ #define NODE_UNDEF NODE_UNDEF
187
+ NODE_CLASS,
188
+ #define NODE_CLASS NODE_CLASS
189
+ NODE_MODULE,
190
+ #define NODE_MODULE NODE_MODULE
191
+ NODE_SCLASS,
192
+ #define NODE_SCLASS NODE_SCLASS
193
+ NODE_COLON2,
194
+ #define NODE_COLON2 NODE_COLON2
195
+ NODE_COLON3,
196
+ #define NODE_COLON3 NODE_COLON3
197
+ NODE_DOT2,
198
+ #define NODE_DOT2 NODE_DOT2
199
+ NODE_DOT3,
200
+ #define NODE_DOT3 NODE_DOT3
201
+ NODE_FLIP2,
202
+ #define NODE_FLIP2 NODE_FLIP2
203
+ NODE_FLIP3,
204
+ #define NODE_FLIP3 NODE_FLIP3
205
+ NODE_ATTRSET,
206
+ #define NODE_ATTRSET NODE_ATTRSET
207
+ NODE_SELF,
208
+ #define NODE_SELF NODE_SELF
209
+ NODE_NIL,
210
+ #define NODE_NIL NODE_NIL
211
+ NODE_TRUE,
212
+ #define NODE_TRUE NODE_TRUE
213
+ NODE_FALSE,
214
+ #define NODE_FALSE NODE_FALSE
215
+ NODE_ERRINFO,
216
+ #define NODE_ERRINFO NODE_ERRINFO
217
+ NODE_DEFINED,
218
+ #define NODE_DEFINED NODE_DEFINED
219
+ NODE_POSTEXE,
220
+ #define NODE_POSTEXE NODE_POSTEXE
221
+ NODE_ALLOCA,
222
+ #define NODE_ALLOCA NODE_ALLOCA
223
+ NODE_BMETHOD,
224
+ #define NODE_BMETHOD NODE_BMETHOD
225
+ NODE_MEMO,
226
+ #define NODE_MEMO NODE_MEMO
227
+ NODE_IFUNC,
228
+ #define NODE_IFUNC NODE_IFUNC
229
+ NODE_DSYM,
230
+ #define NODE_DSYM NODE_DSYM
231
+ NODE_ATTRASGN,
232
+ #define NODE_ATTRASGN NODE_ATTRASGN
233
+ NODE_PRELUDE,
234
+ #define NODE_PRELUDE NODE_PRELUDE
235
+ NODE_LAMBDA,
236
+ #define NODE_LAMBDA NODE_LAMBDA
237
+ NODE_OPTBLOCK,
238
+ #define NODE_OPTBLOCK NODE_OPTBLOCK
239
+ NODE_LAST
240
+ #define NODE_LAST NODE_LAST
241
+ };
242
+
243
+ typedef struct RNode {
244
+ unsigned long flags;
245
+ char *nd_file;
246
+ union {
247
+ struct RNode *node;
248
+ ID id;
249
+ VALUE value;
250
+ VALUE (*cfunc)(ANYARGS);
251
+ ID *tbl;
252
+ } u1;
253
+ union {
254
+ struct RNode *node;
255
+ ID id;
256
+ long argc;
257
+ VALUE value;
258
+ } u2;
259
+ union {
260
+ struct RNode *node;
261
+ ID id;
262
+ long state;
263
+ struct global_entry *entry;
264
+ long cnt;
265
+ VALUE value;
266
+ } u3;
267
+ } NODE;
268
+
269
+ #define RNODE(obj) (R_CAST(RNode)(obj))
270
+
271
+ /* 0..4:T_TYPES, 5:FL_MARK, 6:reserved, 7:NODE_FL_NEWLINE */
272
+ #define NODE_FL_NEWLINE (((VALUE)1)<<7)
273
+
274
+ #define NODE_TYPESHIFT 8
275
+ #define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT)
276
+
277
+ #define nd_type(n) ((int) (((RNODE(n))->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT))
278
+ #define nd_set_type(n,t) \
279
+ RNODE(n)->flags=((RNODE(n)->flags&~NODE_TYPEMASK)|(((t)<<NODE_TYPESHIFT)&NODE_TYPEMASK))
280
+
281
+ #define NODE_LSHIFT (NODE_TYPESHIFT+7)
282
+ #define NODE_LMASK (((SIGNED_VALUE)1<<(sizeof(VALUE)*CHAR_BIT-NODE_LSHIFT))-1)
283
+ #define nd_line(n) ((VALUE)(((RNODE(n))->flags>>NODE_LSHIFT)&NODE_LMASK))
284
+ #define nd_set_line(n,l) \
285
+ RNODE(n)->flags=((RNODE(n)->flags&~(-1<<NODE_LSHIFT))|(((l)&NODE_LMASK)<<NODE_LSHIFT))
286
+
287
+ #define nd_head u1.node
288
+ #define nd_alen u2.argc
289
+ #define nd_next u3.node
290
+
291
+ #define nd_cond u1.node
292
+ #define nd_body u2.node
293
+ #define nd_else u3.node
294
+
295
+ #define nd_orig u3.value
296
+
297
+ #define nd_resq u2.node
298
+ #define nd_ensr u3.node
299
+
300
+ #define nd_1st u1.node
301
+ #define nd_2nd u2.node
302
+
303
+ #define nd_stts u1.node
304
+
305
+ #define nd_entry u3.entry
306
+ #define nd_vid u1.id
307
+ #define nd_cflag u2.id
308
+ #define nd_cval u3.value
309
+
310
+ #define nd_oid u1.id
311
+ #define nd_cnt u3.cnt
312
+ #define nd_tbl u1.tbl
313
+
314
+ #define nd_var u1.node
315
+ #define nd_iter u3.node
316
+
317
+ #define nd_value u2.node
318
+ #define nd_aid u3.id
319
+
320
+ #define nd_lit u1.value
321
+
322
+ #define nd_frml u2.argc
323
+ #define nd_rest u1.id
324
+ #define nd_opt u1.node
325
+ #define nd_pid u1.id
326
+ #define nd_plen u2.argc
327
+
328
+ #define nd_recv u1.node
329
+ #define nd_mid u2.id
330
+ #define nd_args u3.node
331
+
332
+ #define nd_noex u3.id
333
+ #define nd_defn u3.node
334
+
335
+ #define nd_cfnc u1.cfunc
336
+ #define nd_argc u2.argc
337
+
338
+ #define nd_cpath u1.node
339
+ #define nd_super u3.node
340
+
341
+ #define nd_modl u1.id
342
+ #define nd_clss u1.value
343
+
344
+ #define nd_beg u1.node
345
+ #define nd_end u2.node
346
+ #define nd_state u3.state
347
+ #define nd_rval u2.value
348
+
349
+ #define nd_nth u2.argc
350
+
351
+ #define nd_tag u1.id
352
+ #define nd_tval u2.value
353
+
354
+ #define nd_visi u2.argc
355
+
356
+ #define NEW_NODE(t,a0,a1,a2) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2))
357
+
358
+ #define NEW_METHOD(n,x,v) NEW_NODE(NODE_METHOD,x,n,v)
359
+ #define NEW_FBODY(n,i) NEW_NODE(NODE_FBODY,i,n,0)
360
+ #define NEW_DEFN(i,a,d,p) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d))
361
+ #define NEW_DEFS(r,i,a,d) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d))
362
+ #define NEW_CFUNC(f,c) NEW_NODE(NODE_CFUNC,f,c,0)
363
+ #define NEW_IFUNC(f,c) NEW_NODE(NODE_IFUNC,f,c,0)
364
+ #define NEW_SCOPE(a,b) NEW_NODE(NODE_SCOPE,local_tbl(),b,a)
365
+ #define NEW_BLOCK(a) NEW_NODE(NODE_BLOCK,a,0,0)
366
+ #define NEW_IF(c,t,e) NEW_NODE(NODE_IF,c,t,e)
367
+ #define NEW_UNLESS(c,t,e) NEW_IF(c,e,t)
368
+ #define NEW_CASE(h,b) NEW_NODE(NODE_CASE,h,b,0)
369
+ #define NEW_WHEN(c,t,e) NEW_NODE(NODE_WHEN,c,t,e)
370
+ #define NEW_OPT_N(b) NEW_NODE(NODE_OPT_N,0,b,0)
371
+ #define NEW_WHILE(c,b,n) NEW_NODE(NODE_WHILE,c,b,n)
372
+ #define NEW_UNTIL(c,b,n) NEW_NODE(NODE_UNTIL,c,b,n)
373
+ #define NEW_FOR(v,i,b) NEW_NODE(NODE_FOR,v,b,i)
374
+ #define NEW_ITER(a,b) NEW_NODE(NODE_ITER,0,NEW_SCOPE(a,b),0)
375
+ #define NEW_LAMBDA(a) NEW_NODE(NODE_LAMBDA,a,0,0)
376
+ #define NEW_BREAK(s) NEW_NODE(NODE_BREAK,s,0,0)
377
+ #define NEW_NEXT(s) NEW_NODE(NODE_NEXT,s,0,0)
378
+ #define NEW_REDO() NEW_NODE(NODE_REDO,0,0,0)
379
+ #define NEW_RETRY() NEW_NODE(NODE_RETRY,0,0,0)
380
+ #define NEW_BEGIN(b) NEW_NODE(NODE_BEGIN,0,b,0)
381
+ #define NEW_RESCUE(b,res,e) NEW_NODE(NODE_RESCUE,b,res,e)
382
+ #define NEW_RESBODY(a,ex,n) NEW_NODE(NODE_RESBODY,n,ex,a)
383
+ #define NEW_ENSURE(b,en) NEW_NODE(NODE_ENSURE,b,0,en)
384
+ #define NEW_RETURN(s) NEW_NODE(NODE_RETURN,s,0,0)
385
+ #define NEW_YIELD(a,s) NEW_NODE(NODE_YIELD,a,0,s)
386
+ #define NEW_LIST(a) NEW_ARRAY(a)
387
+ #define NEW_ARRAY(a) NEW_NODE(NODE_ARRAY,a,1,0)
388
+ #define NEW_ZARRAY() NEW_NODE(NODE_ZARRAY,0,0,0)
389
+ #define NEW_HASH(a) NEW_NODE(NODE_HASH,a,0,0)
390
+ #define NEW_MASGN(l,r) NEW_NODE(NODE_MASGN,l,0,r)
391
+ #define NEW_GASGN(v,val) NEW_NODE(NODE_GASGN,v,val,rb_global_entry(v))
392
+ #define NEW_LASGN(v,val) NEW_NODE(NODE_LASGN,v,val,0)
393
+ #define NEW_DASGN(v,val) NEW_NODE(NODE_DASGN,v,val,0)
394
+ #define NEW_DASGN_CURR(v,val) NEW_NODE(NODE_DASGN_CURR,v,val,0)
395
+ #define NEW_IASGN(v,val) NEW_NODE(NODE_IASGN,v,val,0)
396
+ #define NEW_IASGN2(v,val) NEW_NODE(NODE_IASGN2,v,val,0)
397
+ #define NEW_CDECL(v,val,path) NEW_NODE(NODE_CDECL,v,val,path)
398
+ #define NEW_CVASGN(v,val) NEW_NODE(NODE_CVASGN,v,val,0)
399
+ #define NEW_CVDECL(v,val) NEW_NODE(NODE_CVDECL,v,val,0)
400
+ #define NEW_OP_ASGN1(p,id,a) NEW_NODE(NODE_OP_ASGN1,p,id,a)
401
+ #define NEW_OP_ASGN2(r,i,o,val) NEW_NODE(NODE_OP_ASGN2,r,val,NEW_OP_ASGN22(i,o))
402
+ #define NEW_OP_ASGN22(i,o) NEW_NODE(NODE_OP_ASGN2,i,o,rb_id_attrset(i))
403
+ #define NEW_OP_ASGN_OR(i,val) NEW_NODE(NODE_OP_ASGN_OR,i,val,0)
404
+ #define NEW_OP_ASGN_AND(i,val) NEW_NODE(NODE_OP_ASGN_AND,i,val,0)
405
+ #define NEW_GVAR(v) NEW_NODE(NODE_GVAR,v,0,rb_global_entry(v))
406
+ #define NEW_LVAR(v) NEW_NODE(NODE_LVAR,v,0,0)
407
+ #define NEW_DVAR(v) NEW_NODE(NODE_DVAR,v,0,0)
408
+ #define NEW_IVAR(v) NEW_NODE(NODE_IVAR,v,0,0)
409
+ #define NEW_CONST(v) NEW_NODE(NODE_CONST,v,0,0)
410
+ #define NEW_CVAR(v) NEW_NODE(NODE_CVAR,v,0,0)
411
+ #define NEW_NTH_REF(n) NEW_NODE(NODE_NTH_REF,0,n,0)
412
+ #define NEW_BACK_REF(n) NEW_NODE(NODE_BACK_REF,0,n,0)
413
+ #define NEW_MATCH(c) NEW_NODE(NODE_MATCH,c,0,0)
414
+ #define NEW_MATCH2(n1,n2) NEW_NODE(NODE_MATCH2,n1,n2,0)
415
+ #define NEW_MATCH3(r,n2) NEW_NODE(NODE_MATCH3,r,n2,0)
416
+ #define NEW_LIT(l) NEW_NODE(NODE_LIT,l,0,0)
417
+ #define NEW_STR(s) NEW_NODE(NODE_STR,s,0,0)
418
+ #define NEW_DSTR(s) NEW_NODE(NODE_DSTR,s,1,0)
419
+ #define NEW_XSTR(s) NEW_NODE(NODE_XSTR,s,0,0)
420
+ #define NEW_DXSTR(s) NEW_NODE(NODE_DXSTR,s,0,0)
421
+ #define NEW_DSYM(s) NEW_NODE(NODE_DSYM,s,0,0)
422
+ #define NEW_EVSTR(n) NEW_NODE(NODE_EVSTR,0,(n),0)
423
+ #define NEW_CALL(r,m,a) NEW_NODE(NODE_CALL,r,m,a)
424
+ #define NEW_FCALL(m,a) NEW_NODE(NODE_FCALL,0,m,a)
425
+ #define NEW_VCALL(m) NEW_NODE(NODE_VCALL,0,m,0)
426
+ #define NEW_SUPER(a) NEW_NODE(NODE_SUPER,0,0,a)
427
+ #define NEW_ZSUPER() NEW_NODE(NODE_ZSUPER,0,0,0)
428
+ #define NEW_ARGS(m,o) NEW_NODE(NODE_ARGS,o,m,0)
429
+ #define NEW_ARGS_AUX(r,b) NEW_NODE(NODE_ARGS_AUX,r,b,0)
430
+ #define NEW_OPT_ARG(i,v) NEW_NODE(NODE_OPT_ARG,i,v,0)
431
+ #define NEW_POSTARG(i,v) NEW_NODE(NODE_POSTARG,i,v,0)
432
+ #define NEW_ARGSCAT(a,b) NEW_NODE(NODE_ARGSCAT,a,b,0)
433
+ #define NEW_ARGSPUSH(a,b) NEW_NODE(NODE_ARGSPUSH,a,b,0)
434
+ #define NEW_SPLAT(a) NEW_NODE(NODE_SPLAT,a,0,0)
435
+ #define NEW_TO_ARY(a) NEW_NODE(NODE_TO_ARY,a,0,0)
436
+ #define NEW_BLOCK_ARG(v) NEW_NODE(NODE_BLOCK_ARG,v,0,local_cnt(v))
437
+ #define NEW_BLOCK_PASS(b) NEW_NODE(NODE_BLOCK_PASS,0,b,0)
438
+ #define NEW_ALIAS(n,o) NEW_NODE(NODE_ALIAS,n,o,0)
439
+ #define NEW_VALIAS(n,o) NEW_NODE(NODE_VALIAS,n,o,0)
440
+ #define NEW_UNDEF(i) NEW_NODE(NODE_UNDEF,0,i,0)
441
+ #define NEW_CLASS(n,b,s) NEW_NODE(NODE_CLASS,n,NEW_SCOPE(0,b),(s))
442
+ #define NEW_SCLASS(r,b) NEW_NODE(NODE_SCLASS,r,NEW_SCOPE(0,b),0)
443
+ #define NEW_MODULE(n,b) NEW_NODE(NODE_MODULE,n,NEW_SCOPE(0,b),0)
444
+ #define NEW_COLON2(c,i) NEW_NODE(NODE_COLON2,c,i,0)
445
+ #define NEW_COLON3(i) NEW_NODE(NODE_COLON3,0,i,0)
446
+ #define NEW_DOT2(b,e) NEW_NODE(NODE_DOT2,b,e,0)
447
+ #define NEW_DOT3(b,e) NEW_NODE(NODE_DOT3,b,e,0)
448
+ #define NEW_ATTRSET(a) NEW_NODE(NODE_ATTRSET,a,0,0)
449
+ #define NEW_SELF() NEW_NODE(NODE_SELF,0,0,0)
450
+ #define NEW_NIL() NEW_NODE(NODE_NIL,0,0,0)
451
+ #define NEW_TRUE() NEW_NODE(NODE_TRUE,0,0,0)
452
+ #define NEW_FALSE() NEW_NODE(NODE_FALSE,0,0,0)
453
+ #define NEW_ERRINFO() NEW_NODE(NODE_ERRINFO,0,0,0)
454
+ #define NEW_DEFINED(e) NEW_NODE(NODE_DEFINED,e,0,0)
455
+ #define NEW_PREEXE(b) NEW_SCOPE(b)
456
+ #define NEW_POSTEXE(b) NEW_NODE(NODE_POSTEXE,0,b,0)
457
+ #define NEW_BMETHOD(b) NEW_NODE(NODE_BMETHOD,0,0,b)
458
+ #define NEW_ATTRASGN(r,m,a) NEW_NODE(NODE_ATTRASGN,r,m,a)
459
+ #define NEW_PRELUDE(p,b) NEW_NODE(NODE_PRELUDE,p,b,0)
460
+ #define NEW_OPTBLOCK(a) NEW_NODE(NODE_OPTBLOCK,a,0,0)
461
+
462
+ #define NOEX_PUBLIC 0x00
463
+ #define NOEX_NOSUPER 0x01
464
+ #define NOEX_PRIVATE 0x02
465
+ #define NOEX_PROTECTED 0x04
466
+ #define NOEX_MASK 0x06 /* 0110 */
467
+ #define NOEX_BASIC 0x08
468
+
469
+ #define NOEX_UNDEF NOEX_NOSUPER
470
+
471
+ #define NOEX_MODFUNC 0x12
472
+ #define NOEX_SUPER 0x20
473
+ #define NOEX_VCALL 0x40
474
+
475
+ #define NOEX_SAFE(n) (((n) >> 8) & 0x0F)
476
+ #define NOEX_WITH(n, s) ((s << 8) | (n) | (ruby_running ? 0 : NOEX_BASIC))
477
+ #define NOEX_WITH_SAFE(n) NOEX_WITH(n, rb_safe_level())
478
+
479
+ #define CALL_PUBLIC 0
480
+ #define CALL_FCALL 1
481
+ #define CALL_VCALL 2
482
+ #define CALL_SUPER 3
483
+
484
+ #define RUBY_VM_METHOD_NODE NODE_METHOD
485
+
486
+ VALUE rb_parser_new(void);
487
+ VALUE rb_parser_end_seen_p(VALUE);
488
+ VALUE rb_parser_encoding(VALUE);
489
+
490
+ NODE *rb_parser_compile_cstr(volatile VALUE, const char*, const char*, int, int);
491
+ NODE *rb_parser_compile_string(volatile VALUE, const char*, VALUE, int);
492
+ NODE *rb_parser_compile_file(volatile VALUE, const char*, VALUE, int);
493
+
494
+ NODE *rb_compile_cstr(const char*, const char*, int, int);
495
+ NODE *rb_compile_string(const char*, VALUE, int);
496
+ NODE *rb_compile_file(const char*, VALUE, int);
497
+
498
+ void rb_add_method(VALUE, ID, NODE *, int);
499
+ NODE *rb_node_newnode(enum node_type,VALUE,VALUE,VALUE);
500
+
501
+ NODE* rb_method_node(VALUE klass, ID id);
502
+ int rb_node_arity(NODE* node);
503
+
504
+ struct global_entry *rb_global_entry(ID);
505
+ VALUE rb_gvar_get(struct global_entry *);
506
+ VALUE rb_gvar_set(struct global_entry *, VALUE);
507
+ VALUE rb_gvar_defined(struct global_entry *);
508
+
509
+ #if defined(__cplusplus)
510
+ #if 0
511
+ { /* satisfy cc-mode */
512
+ #endif
513
+ } /* extern "C" { */
514
+ #endif
515
+
516
+ #endif /* RUBY_NODE_H */
@@ -0,0 +1,189 @@
1
+
2
+ /* A Bison parser, made by GNU Bison 2.4.1. */
3
+
4
+ /* Skeleton interface for Bison's Yacc-like parsers in C
5
+
6
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7
+ Free Software Foundation, Inc.
8
+
9
+ This program is free software: you can redistribute it and/or modify
10
+ it under the terms of the GNU General Public License as published by
11
+ the Free Software Foundation, either version 3 of the License, or
12
+ (at your option) any later version.
13
+
14
+ This program is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ GNU General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License
20
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
+
22
+ /* As a special exception, you may create a larger work that contains
23
+ part or all of the Bison parser skeleton and distribute that work
24
+ under terms of your choice, so long as that work isn't itself a
25
+ parser generator using the skeleton or a modified version thereof
26
+ as a parser skeleton. Alternatively, if you modify or redistribute
27
+ the parser skeleton itself, you may (at your option) remove this
28
+ special exception, which will cause the skeleton and the resulting
29
+ Bison output files to be licensed under the GNU General Public
30
+ License without this special exception.
31
+
32
+ This special exception was added by the Free Software Foundation in
33
+ version 2.2 of Bison. */
34
+
35
+
36
+ /* Tokens. */
37
+ #ifndef YYTOKENTYPE
38
+ # define YYTOKENTYPE
39
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
40
+ know about them. */
41
+ enum yytokentype {
42
+ keyword_class = 258,
43
+ keyword_module = 259,
44
+ keyword_def = 260,
45
+ keyword_undef = 261,
46
+ keyword_begin = 262,
47
+ keyword_rescue = 263,
48
+ keyword_ensure = 264,
49
+ keyword_end = 265,
50
+ keyword_if = 266,
51
+ keyword_unless = 267,
52
+ keyword_then = 268,
53
+ keyword_elsif = 269,
54
+ keyword_else = 270,
55
+ keyword_case = 271,
56
+ keyword_when = 272,
57
+ keyword_while = 273,
58
+ keyword_until = 274,
59
+ keyword_for = 275,
60
+ keyword_break = 276,
61
+ keyword_next = 277,
62
+ keyword_redo = 278,
63
+ keyword_retry = 279,
64
+ keyword_in = 280,
65
+ keyword_do = 281,
66
+ keyword_do_cond = 282,
67
+ keyword_do_block = 283,
68
+ keyword_do_LAMBDA = 284,
69
+ keyword_return = 285,
70
+ keyword_yield = 286,
71
+ keyword_super = 287,
72
+ keyword_self = 288,
73
+ keyword_nil = 289,
74
+ keyword_true = 290,
75
+ keyword_false = 291,
76
+ keyword_and = 292,
77
+ keyword_or = 293,
78
+ keyword_not = 294,
79
+ modifier_if = 295,
80
+ modifier_unless = 296,
81
+ modifier_while = 297,
82
+ modifier_until = 298,
83
+ modifier_rescue = 299,
84
+ keyword_alias = 300,
85
+ keyword_defined = 301,
86
+ keyword_BEGIN = 302,
87
+ keyword_END = 303,
88
+ keyword__LINE__ = 304,
89
+ keyword__FILE__ = 305,
90
+ keyword__ENCODING__ = 306,
91
+ tIDENTIFIER = 307,
92
+ tFID = 308,
93
+ tGVAR = 309,
94
+ tIVAR = 310,
95
+ tCONSTANT = 311,
96
+ tCVAR = 312,
97
+ tLABEL = 313,
98
+ tINTEGER = 314,
99
+ tFLOAT = 315,
100
+ tSTRING_CONTENT = 316,
101
+ tCHAR = 317,
102
+ tNTH_REF = 318,
103
+ tBACK_REF = 319,
104
+ tREGEXP_END = 320,
105
+ tUPLUS = 321,
106
+ tUMINUS = 322,
107
+ tPOW = 323,
108
+ tCMP = 324,
109
+ tEQ = 325,
110
+ tEQQ = 326,
111
+ tNEQ = 327,
112
+ tGEQ = 328,
113
+ tLEQ = 329,
114
+ tANDOP = 330,
115
+ tOROP = 331,
116
+ tMATCH = 332,
117
+ tNMATCH = 333,
118
+ tDOT2 = 334,
119
+ tDOT3 = 335,
120
+ tAREF = 336,
121
+ tASET = 337,
122
+ tLSHFT = 338,
123
+ tRSHFT = 339,
124
+ tCOLON2 = 340,
125
+ tCOLON3 = 341,
126
+ tOP_ASGN = 342,
127
+ tASSOC = 343,
128
+ tLPAREN = 344,
129
+ tLPAREN_ARG = 345,
130
+ tRPAREN = 346,
131
+ tLBRACK = 347,
132
+ tLBRACE = 348,
133
+ tLBRACE_ARG = 349,
134
+ tSTAR = 350,
135
+ tAMPER = 351,
136
+ tLAMBDA = 352,
137
+ tSYMBEG = 353,
138
+ tSTRING_BEG = 354,
139
+ tXSTRING_BEG = 355,
140
+ tREGEXP_BEG = 356,
141
+ tWORDS_BEG = 357,
142
+ tQWORDS_BEG = 358,
143
+ tSTRING_DBEG = 359,
144
+ tSTRING_DVAR = 360,
145
+ tSTRING_END = 361,
146
+ tLAMBEG = 362,
147
+ tLOWEST = 363,
148
+ tUMINUS_NUM = 364,
149
+ idNULL = 365,
150
+ idRespond_to = 366,
151
+ idIFUNC = 367,
152
+ idCFUNC = 368,
153
+ idThrowState = 369,
154
+ id_core_set_method_alias = 370,
155
+ id_core_set_variable_alias = 371,
156
+ id_core_undef_method = 372,
157
+ id_core_define_method = 373,
158
+ id_core_define_singleton_method = 374,
159
+ id_core_set_postexe = 375,
160
+ tLAST_TOKEN = 376
161
+ };
162
+ #endif
163
+
164
+
165
+
166
+ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
167
+ typedef union YYSTYPE
168
+ {
169
+
170
+ /* Line 1676 of yacc.c */
171
+
172
+ VALUE val;
173
+ NODE *node;
174
+ ID id;
175
+ int num;
176
+ const struct vtable *vars;
177
+
178
+
179
+
180
+ /* Line 1676 of yacc.c */
181
+ } YYSTYPE;
182
+ # define YYSTYPE_IS_TRIVIAL 1
183
+ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
184
+ # define YYSTYPE_IS_DECLARED 1
185
+ #endif
186
+
187
+
188
+
189
+