debase-ruby_core_source 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -1
  3. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/addr2line.h +21 -0
  4. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/ccan/build_assert/build_assert.h +40 -0
  5. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/ccan/check_type/check_type.h +63 -0
  6. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/ccan/container_of/container_of.h +142 -0
  7. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/ccan/list/list.h +773 -0
  8. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/ccan/str/str.h +16 -0
  9. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/constant.h +50 -0
  10. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/dln.h +51 -0
  11. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/encindex.h +67 -0
  12. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/eval_intern.h +304 -0
  13. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/gc.h +114 -0
  14. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/id.h +211 -0
  15. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/id_table.h +30 -0
  16. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/insns.inc +110 -0
  17. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/insns_info.inc +776 -0
  18. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/internal.h +1407 -0
  19. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/iseq.h +249 -0
  20. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/known_errors.inc +746 -0
  21. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/method.h +213 -0
  22. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/node.h +520 -0
  23. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/node_name.inc +208 -0
  24. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/opt_sc.inc +758 -0
  25. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/optinsn.inc +83 -0
  26. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/optunifs.inc +127 -0
  27. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/parse.h +185 -0
  28. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/probes_helper.h +43 -0
  29. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/regenc.h +237 -0
  30. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/regint.h +987 -0
  31. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/regparse.h +367 -0
  32. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/revision.h +1 -0
  33. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/ruby_atomic.h +233 -0
  34. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/siphash.h +48 -0
  35. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/symbol.h +108 -0
  36. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/thread_pthread.h +54 -0
  37. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/thread_win32.h +36 -0
  38. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/timev.h +42 -0
  39. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/transcode_data.h +139 -0
  40. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/version.h +55 -0
  41. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vm.inc +3414 -0
  42. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vm_call_iseq_optimized.inc +212 -0
  43. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vm_core.h +1240 -0
  44. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vm_debug.h +37 -0
  45. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vm_exec.h +182 -0
  46. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vm_insnhelper.h +227 -0
  47. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vm_opts.h +57 -0
  48. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vmtc.inc +108 -0
  49. data/lib/debase/ruby_core_source/version.rb +1 -1
  50. metadata +48 -2
@@ -0,0 +1,213 @@
1
+ /**********************************************************************
2
+
3
+ method.h -
4
+
5
+ $Author: nagachika $
6
+ created at: Wed Jul 15 20:02:33 2009
7
+
8
+ Copyright (C) 2009 Koichi Sasada
9
+
10
+ **********************************************************************/
11
+ #ifndef RUBY_METHOD_H
12
+ #define RUBY_METHOD_H 1
13
+
14
+ #include "internal.h"
15
+
16
+ #ifndef END_OF_ENUMERATION
17
+ # if defined(__GNUC__) &&! defined(__STRICT_ANSI__)
18
+ # define END_OF_ENUMERATION(key)
19
+ # else
20
+ # define END_OF_ENUMERATION(key) END_OF_##key##_PLACEHOLDER = 0
21
+ # endif
22
+ #endif
23
+
24
+ /* cref */
25
+
26
+ typedef enum {
27
+ METHOD_VISI_UNDEF = 0x00,
28
+ METHOD_VISI_PUBLIC = 0x01,
29
+ METHOD_VISI_PRIVATE = 0x02,
30
+ METHOD_VISI_PROTECTED = 0x03,
31
+
32
+ METHOD_VISI_MASK = 0x03
33
+ } rb_method_visibility_t;
34
+
35
+ typedef struct rb_scope_visi_struct {
36
+ rb_method_visibility_t method_visi : 3;
37
+ unsigned int module_func : 1;
38
+ } rb_scope_visibility_t;
39
+
40
+ typedef struct rb_cref_struct {
41
+ VALUE flags;
42
+ const VALUE refinements;
43
+ const VALUE klass;
44
+ struct rb_cref_struct * const next;
45
+ const rb_scope_visibility_t scope_visi;
46
+ } rb_cref_t;
47
+
48
+ /* method data type */
49
+
50
+ typedef struct rb_method_entry_struct {
51
+ VALUE flags;
52
+ const VALUE defined_class;
53
+ struct rb_method_definition_struct * const def;
54
+ ID called_id;
55
+ const VALUE owner;
56
+ } rb_method_entry_t;
57
+
58
+ typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_entry_t */
59
+ VALUE flags;
60
+ const VALUE defined_class;
61
+ struct rb_method_definition_struct * const def;
62
+ ID called_id;
63
+ const VALUE owner;
64
+ } rb_callable_method_entry_t;
65
+
66
+ #define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
67
+ #define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
68
+ #define METHOD_ENTRY_COMPLEMENTED(me) ((me)->flags & IMEMO_FL_USER3)
69
+ #define METHOD_ENTRY_COMPLEMENTED_SET(me) ((me)->flags = (me)->flags | IMEMO_FL_USER3)
70
+
71
+ static inline void
72
+ METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
73
+ {
74
+ VM_ASSERT((int)visi >= 0 && visi <= 3);
75
+ me->flags = (me->flags & ~(IMEMO_FL_USER0 | IMEMO_FL_USER1)) | (visi << (IMEMO_FL_USHIFT+0));
76
+ }
77
+ static inline void
78
+ METHOD_ENTRY_BASIC_SET(rb_method_entry_t *me, unsigned int basic)
79
+ {
80
+ VM_ASSERT(basic <= 1);
81
+ me->flags = (me->flags & ~(IMEMO_FL_USER2 )) | (basic << (IMEMO_FL_USHIFT+2));
82
+ }
83
+ static inline void
84
+ METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, unsigned int basic)
85
+ {
86
+ VM_ASSERT((int)visi >= 0 && visi <= 3);
87
+ VM_ASSERT(basic <= 1);
88
+ me->flags =
89
+ (me->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
90
+ ((visi << (IMEMO_FL_USHIFT+0)) | (basic << (IMEMO_FL_USHIFT+2)));
91
+ }
92
+ static inline void
93
+ METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
94
+ {
95
+ dst->flags =
96
+ (dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
97
+ (src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2));
98
+ }
99
+
100
+ typedef enum {
101
+ VM_METHOD_TYPE_ISEQ,
102
+ VM_METHOD_TYPE_CFUNC,
103
+ VM_METHOD_TYPE_ATTRSET,
104
+ VM_METHOD_TYPE_IVAR,
105
+ VM_METHOD_TYPE_BMETHOD,
106
+ VM_METHOD_TYPE_ZSUPER,
107
+ VM_METHOD_TYPE_ALIAS,
108
+ VM_METHOD_TYPE_UNDEF,
109
+ VM_METHOD_TYPE_NOTIMPLEMENTED,
110
+ VM_METHOD_TYPE_OPTIMIZED, /* Kernel#send, Proc#call, etc */
111
+ VM_METHOD_TYPE_MISSING, /* wrapper for method_missing(id) */
112
+ VM_METHOD_TYPE_REFINED,
113
+
114
+ END_OF_ENUMERATION(VM_METHOD_TYPE)
115
+ } rb_method_type_t;
116
+
117
+ #ifndef rb_iseq_t
118
+ typedef struct rb_iseq_struct rb_iseq_t;
119
+ #define rb_iseq_t rb_iseq_t
120
+ #endif
121
+
122
+ typedef struct rb_method_iseq_struct {
123
+ const rb_iseq_t * const iseqptr; /* should be separated from iseqval */
124
+ rb_cref_t * const cref; /* should be marked */
125
+ } rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */
126
+
127
+ typedef struct rb_method_cfunc_struct {
128
+ VALUE (*func)(ANYARGS);
129
+ VALUE (*invoker)(VALUE (*func)(ANYARGS), VALUE recv, int argc, const VALUE *argv);
130
+ int argc;
131
+ } rb_method_cfunc_t;
132
+
133
+ typedef struct rb_method_attr_struct {
134
+ ID id;
135
+ const VALUE location; /* should be marked */
136
+ } rb_method_attr_t;
137
+
138
+ typedef struct rb_method_alias_struct {
139
+ const struct rb_method_entry_struct * const original_me; /* original_me->klass is original owner */
140
+ } rb_method_alias_t;
141
+
142
+ typedef struct rb_method_refined_struct {
143
+ const struct rb_method_entry_struct * const orig_me;
144
+ const VALUE owner;
145
+ } rb_method_refined_t;
146
+
147
+ typedef struct rb_method_definition_struct {
148
+ rb_method_type_t type : 8; /* method type */
149
+ int alias_count : 28;
150
+ int complemented_count: 28;
151
+
152
+ union {
153
+ rb_method_iseq_t iseq;
154
+ rb_method_cfunc_t cfunc;
155
+ rb_method_attr_t attr;
156
+ rb_method_alias_t alias;
157
+ rb_method_refined_t refined;
158
+
159
+ const VALUE proc; /* should be marked */
160
+ enum method_optimized_type {
161
+ OPTIMIZED_METHOD_TYPE_SEND,
162
+ OPTIMIZED_METHOD_TYPE_CALL,
163
+
164
+ OPTIMIZED_METHOD_TYPE__MAX
165
+ } optimize_type;
166
+ } body;
167
+
168
+ ID original_id;
169
+ } rb_method_definition_t;
170
+
171
+ #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
172
+ #define UNDEFINED_REFINED_METHOD_P(def) \
173
+ ((def)->type == VM_METHOD_TYPE_REFINED && \
174
+ UNDEFINED_METHOD_ENTRY_P((def)->body.refined.orig_me))
175
+
176
+ void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_visibility_t visi);
177
+ void rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi);
178
+ void rb_add_refined_method_entry(VALUE refined_class, ID mid);
179
+
180
+ rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_visibility_t visi);
181
+ rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex);
182
+ rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, const rb_method_definition_t *def);
183
+
184
+ const rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
185
+
186
+ const rb_method_entry_t *rb_method_entry(VALUE klass, ID id);
187
+ const rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id);
188
+ const rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id);
189
+ const rb_method_entry_t *rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
190
+
191
+ const rb_callable_method_entry_t *rb_callable_method_entry(VALUE klass, ID id);
192
+ const rb_callable_method_entry_t *rb_callable_method_entry_with_refinements(VALUE klass, ID id);
193
+ const rb_callable_method_entry_t *rb_callable_method_entry_without_refinements(VALUE klass, ID id);
194
+ const rb_callable_method_entry_t *rb_resolve_refined_method_callable(VALUE refinements, const rb_callable_method_entry_t *me);
195
+
196
+ int rb_method_entry_arity(const rb_method_entry_t *me);
197
+ int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2);
198
+ st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me);
199
+
200
+ VALUE rb_method_entry_location(const rb_method_entry_t *me);
201
+ VALUE rb_mod_method_location(VALUE mod, ID id);
202
+ VALUE rb_obj_method_location(VALUE obj, ID id);
203
+
204
+ void rb_free_method_entry(const rb_method_entry_t *me);
205
+ void rb_sweep_method_entry(void *vm);
206
+
207
+ const rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
208
+ 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);
209
+ void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src);
210
+
211
+ void rb_scope_visibility_set(rb_method_visibility_t);
212
+
213
+ #endif /* RUBY_METHOD_H */
@@ -0,0 +1,520 @@
1
+ /**********************************************************************
2
+
3
+ node.h -
4
+
5
+ $Author: hsbt $
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_SCOPE,
24
+ #define NODE_SCOPE NODE_SCOPE
25
+ NODE_BLOCK,
26
+ #define NODE_BLOCK NODE_BLOCK
27
+ NODE_IF,
28
+ #define NODE_IF NODE_IF
29
+ NODE_CASE,
30
+ #define NODE_CASE NODE_CASE
31
+ NODE_WHEN,
32
+ #define NODE_WHEN NODE_WHEN
33
+ NODE_OPT_N,
34
+ #define NODE_OPT_N NODE_OPT_N
35
+ NODE_WHILE,
36
+ #define NODE_WHILE NODE_WHILE
37
+ NODE_UNTIL,
38
+ #define NODE_UNTIL NODE_UNTIL
39
+ NODE_ITER,
40
+ #define NODE_ITER NODE_ITER
41
+ NODE_FOR,
42
+ #define NODE_FOR NODE_FOR
43
+ NODE_BREAK,
44
+ #define NODE_BREAK NODE_BREAK
45
+ NODE_NEXT,
46
+ #define NODE_NEXT NODE_NEXT
47
+ NODE_REDO,
48
+ #define NODE_REDO NODE_REDO
49
+ NODE_RETRY,
50
+ #define NODE_RETRY NODE_RETRY
51
+ NODE_BEGIN,
52
+ #define NODE_BEGIN NODE_BEGIN
53
+ NODE_RESCUE,
54
+ #define NODE_RESCUE NODE_RESCUE
55
+ NODE_RESBODY,
56
+ #define NODE_RESBODY NODE_RESBODY
57
+ NODE_ENSURE,
58
+ #define NODE_ENSURE NODE_ENSURE
59
+ NODE_AND,
60
+ #define NODE_AND NODE_AND
61
+ NODE_OR,
62
+ #define NODE_OR NODE_OR
63
+ NODE_MASGN,
64
+ #define NODE_MASGN NODE_MASGN
65
+ NODE_LASGN,
66
+ #define NODE_LASGN NODE_LASGN
67
+ NODE_DASGN,
68
+ #define NODE_DASGN NODE_DASGN
69
+ NODE_DASGN_CURR,
70
+ #define NODE_DASGN_CURR NODE_DASGN_CURR
71
+ NODE_GASGN,
72
+ #define NODE_GASGN NODE_GASGN
73
+ NODE_IASGN,
74
+ #define NODE_IASGN NODE_IASGN
75
+ NODE_IASGN2,
76
+ #define NODE_IASGN2 NODE_IASGN2
77
+ NODE_CDECL,
78
+ #define NODE_CDECL NODE_CDECL
79
+ NODE_CVASGN,
80
+ #define NODE_CVASGN NODE_CVASGN
81
+ NODE_CVDECL,
82
+ #define NODE_CVDECL NODE_CVDECL
83
+ NODE_OP_ASGN1,
84
+ #define NODE_OP_ASGN1 NODE_OP_ASGN1
85
+ NODE_OP_ASGN2,
86
+ #define NODE_OP_ASGN2 NODE_OP_ASGN2
87
+ NODE_OP_ASGN_AND,
88
+ #define NODE_OP_ASGN_AND NODE_OP_ASGN_AND
89
+ NODE_OP_ASGN_OR,
90
+ #define NODE_OP_ASGN_OR NODE_OP_ASGN_OR
91
+ NODE_OP_CDECL,
92
+ #define NODE_OP_CDECL NODE_OP_CDECL
93
+ NODE_CALL,
94
+ #define NODE_CALL NODE_CALL
95
+ NODE_FCALL,
96
+ #define NODE_FCALL NODE_FCALL
97
+ NODE_VCALL,
98
+ #define NODE_VCALL NODE_VCALL
99
+ NODE_QCALL,
100
+ #define NODE_QCALL NODE_QCALL
101
+ NODE_SUPER,
102
+ #define NODE_SUPER NODE_SUPER
103
+ NODE_ZSUPER,
104
+ #define NODE_ZSUPER NODE_ZSUPER
105
+ NODE_ARRAY,
106
+ #define NODE_ARRAY NODE_ARRAY
107
+ NODE_ZARRAY,
108
+ #define NODE_ZARRAY NODE_ZARRAY
109
+ NODE_VALUES,
110
+ #define NODE_VALUES NODE_VALUES
111
+ NODE_HASH,
112
+ #define NODE_HASH NODE_HASH
113
+ NODE_RETURN,
114
+ #define NODE_RETURN NODE_RETURN
115
+ NODE_YIELD,
116
+ #define NODE_YIELD NODE_YIELD
117
+ NODE_LVAR,
118
+ #define NODE_LVAR NODE_LVAR
119
+ NODE_DVAR,
120
+ #define NODE_DVAR NODE_DVAR
121
+ NODE_GVAR,
122
+ #define NODE_GVAR NODE_GVAR
123
+ NODE_IVAR,
124
+ #define NODE_IVAR NODE_IVAR
125
+ NODE_CONST,
126
+ #define NODE_CONST NODE_CONST
127
+ NODE_CVAR,
128
+ #define NODE_CVAR NODE_CVAR
129
+ NODE_NTH_REF,
130
+ #define NODE_NTH_REF NODE_NTH_REF
131
+ NODE_BACK_REF,
132
+ #define NODE_BACK_REF NODE_BACK_REF
133
+ NODE_MATCH,
134
+ #define NODE_MATCH NODE_MATCH
135
+ NODE_MATCH2,
136
+ #define NODE_MATCH2 NODE_MATCH2
137
+ NODE_MATCH3,
138
+ #define NODE_MATCH3 NODE_MATCH3
139
+ NODE_LIT,
140
+ #define NODE_LIT NODE_LIT
141
+ NODE_STR,
142
+ #define NODE_STR NODE_STR
143
+ NODE_DSTR,
144
+ #define NODE_DSTR NODE_DSTR
145
+ NODE_XSTR,
146
+ #define NODE_XSTR NODE_XSTR
147
+ NODE_DXSTR,
148
+ #define NODE_DXSTR NODE_DXSTR
149
+ NODE_EVSTR,
150
+ #define NODE_EVSTR NODE_EVSTR
151
+ NODE_DREGX,
152
+ #define NODE_DREGX NODE_DREGX
153
+ NODE_DREGX_ONCE,
154
+ #define NODE_DREGX_ONCE NODE_DREGX_ONCE
155
+ NODE_ARGS,
156
+ #define NODE_ARGS NODE_ARGS
157
+ NODE_ARGS_AUX,
158
+ #define NODE_ARGS_AUX NODE_ARGS_AUX
159
+ NODE_OPT_ARG,
160
+ #define NODE_OPT_ARG NODE_OPT_ARG
161
+ NODE_KW_ARG,
162
+ #define NODE_KW_ARG NODE_KW_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_SELF,
206
+ #define NODE_SELF NODE_SELF
207
+ NODE_NIL,
208
+ #define NODE_NIL NODE_NIL
209
+ NODE_TRUE,
210
+ #define NODE_TRUE NODE_TRUE
211
+ NODE_FALSE,
212
+ #define NODE_FALSE NODE_FALSE
213
+ NODE_ERRINFO,
214
+ #define NODE_ERRINFO NODE_ERRINFO
215
+ NODE_DEFINED,
216
+ #define NODE_DEFINED NODE_DEFINED
217
+ NODE_POSTEXE,
218
+ #define NODE_POSTEXE NODE_POSTEXE
219
+ NODE_ALLOCA,
220
+ #define NODE_ALLOCA NODE_ALLOCA
221
+ NODE_BMETHOD,
222
+ #define NODE_BMETHOD NODE_BMETHOD
223
+ NODE_DSYM,
224
+ #define NODE_DSYM NODE_DSYM
225
+ NODE_ATTRASGN,
226
+ #define NODE_ATTRASGN NODE_ATTRASGN
227
+ NODE_PRELUDE,
228
+ #define NODE_PRELUDE NODE_PRELUDE
229
+ NODE_LAMBDA,
230
+ #define NODE_LAMBDA NODE_LAMBDA
231
+ NODE_LAST
232
+ #define NODE_LAST NODE_LAST
233
+ };
234
+
235
+ typedef struct RNode {
236
+ VALUE flags;
237
+ VALUE nd_reserved; /* ex nd_file */
238
+ union {
239
+ struct RNode *node;
240
+ ID id;
241
+ VALUE value;
242
+ VALUE (*cfunc)(ANYARGS);
243
+ ID *tbl;
244
+ } u1;
245
+ union {
246
+ struct RNode *node;
247
+ ID id;
248
+ long argc;
249
+ VALUE value;
250
+ } u2;
251
+ union {
252
+ struct RNode *node;
253
+ ID id;
254
+ long state;
255
+ struct rb_global_entry *entry;
256
+ struct rb_args_info *args;
257
+ long cnt;
258
+ VALUE value;
259
+ } u3;
260
+ } NODE;
261
+
262
+ #define RNODE(obj) (R_CAST(RNode)(obj))
263
+
264
+ /* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8: TAINT, 9: UNTRUSTED, 10: EXIVAR, 11: FREEZE */
265
+ /* NODE_FL: 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: NODE_FL_NEWLINE|NODE_FL_CREF_PUSHED_BY_EVAL,
266
+ * 8..14: nd_type,
267
+ * 15..: nd_line
268
+ */
269
+ #define NODE_FL_NEWLINE (((VALUE)1)<<7)
270
+
271
+ #define NODE_TYPESHIFT 8
272
+ #define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT)
273
+
274
+ #define nd_type(n) ((int) (((RNODE(n))->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT))
275
+ #define nd_set_type(n,t) \
276
+ RNODE(n)->flags=((RNODE(n)->flags&~NODE_TYPEMASK)|((((unsigned long)(t))<<NODE_TYPESHIFT)&NODE_TYPEMASK))
277
+
278
+ #define NODE_LSHIFT (NODE_TYPESHIFT+7)
279
+ #define NODE_LMASK (((SIGNED_VALUE)1<<(sizeof(VALUE)*CHAR_BIT-NODE_LSHIFT))-1)
280
+ #define nd_line(n) (int)(RNODE(n)->flags>>NODE_LSHIFT)
281
+ #define nd_set_line(n,l) \
282
+ RNODE(n)->flags=((RNODE(n)->flags&~((VALUE)(-1)<<NODE_LSHIFT))|((VALUE)((l)&NODE_LMASK)<<NODE_LSHIFT))
283
+
284
+ #define nd_refinements_ nd_reserved
285
+
286
+ #define nd_head u1.node
287
+ #define nd_alen u2.argc
288
+ #define nd_next u3.node
289
+
290
+ #define nd_cond u1.node
291
+ #define nd_body u2.node
292
+ #define nd_else u3.node
293
+
294
+ #define nd_orig u3.value
295
+
296
+ #define nd_resq u2.node
297
+ #define nd_ensr u3.node
298
+
299
+ #define nd_1st u1.node
300
+ #define nd_2nd u2.node
301
+
302
+ #define nd_stts u1.node
303
+
304
+ #define nd_entry u3.entry
305
+ #define nd_vid u1.id
306
+ #define nd_cflag u2.id
307
+ #define nd_cval u3.value
308
+
309
+ #define nd_oid u1.id
310
+ #define nd_cnt u3.cnt
311
+ #define nd_tbl u1.tbl
312
+
313
+ #define nd_var u1.node
314
+ #define nd_iter u3.node
315
+
316
+ #define nd_value u2.node
317
+ #define nd_aid u3.id
318
+
319
+ #define nd_lit u1.value
320
+
321
+ #define nd_frml u2.argc
322
+ #define nd_rest u1.id
323
+ #define nd_opt u1.node
324
+ #define nd_pid u1.id
325
+ #define nd_plen u2.argc
326
+
327
+ #define nd_recv u1.node
328
+ #define nd_mid u2.id
329
+ #define nd_args u3.node
330
+ #define nd_ainfo u3.args
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_DEFN(i,a,d,p) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d))
359
+ #define NEW_DEFS(r,i,a,d) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d))
360
+ #define NEW_SCOPE(a,b) NEW_NODE(NODE_SCOPE,local_tbl(),b,a)
361
+ #define NEW_BLOCK(a) NEW_NODE(NODE_BLOCK,a,0,0)
362
+ #define NEW_IF(c,t,e) NEW_NODE(NODE_IF,c,t,e)
363
+ #define NEW_UNLESS(c,t,e) NEW_IF(c,e,t)
364
+ #define NEW_CASE(h,b) NEW_NODE(NODE_CASE,h,b,0)
365
+ #define NEW_WHEN(c,t,e) NEW_NODE(NODE_WHEN,c,t,e)
366
+ #define NEW_OPT_N(b) NEW_NODE(NODE_OPT_N,0,b,0)
367
+ #define NEW_WHILE(c,b,n) NEW_NODE(NODE_WHILE,c,b,n)
368
+ #define NEW_UNTIL(c,b,n) NEW_NODE(NODE_UNTIL,c,b,n)
369
+ #define NEW_FOR(v,i,b) NEW_NODE(NODE_FOR,v,b,i)
370
+ #define NEW_ITER(a,b) NEW_NODE(NODE_ITER,0,NEW_SCOPE(a,b),0)
371
+ #define NEW_LAMBDA(a,b) NEW_NODE(NODE_LAMBDA,0,NEW_SCOPE(a,b),0)
372
+ #define NEW_BREAK(s) NEW_NODE(NODE_BREAK,s,0,0)
373
+ #define NEW_NEXT(s) NEW_NODE(NODE_NEXT,s,0,0)
374
+ #define NEW_REDO() NEW_NODE(NODE_REDO,0,0,0)
375
+ #define NEW_RETRY() NEW_NODE(NODE_RETRY,0,0,0)
376
+ #define NEW_BEGIN(b) NEW_NODE(NODE_BEGIN,0,b,0)
377
+ #define NEW_RESCUE(b,res,e) NEW_NODE(NODE_RESCUE,b,res,e)
378
+ #define NEW_RESBODY(a,ex,n) NEW_NODE(NODE_RESBODY,n,ex,a)
379
+ #define NEW_ENSURE(b,en) NEW_NODE(NODE_ENSURE,b,0,en)
380
+ #define NEW_RETURN(s) NEW_NODE(NODE_RETURN,s,0,0)
381
+ #define NEW_YIELD(a) NEW_NODE(NODE_YIELD,a,0,0)
382
+ #define NEW_LIST(a) NEW_ARRAY(a)
383
+ #define NEW_ARRAY(a) NEW_NODE(NODE_ARRAY,a,1,0)
384
+ #define NEW_ZARRAY() NEW_NODE(NODE_ZARRAY,0,0,0)
385
+ #define NEW_HASH(a) NEW_NODE(NODE_HASH,a,0,0)
386
+ #define NEW_MASGN(l,r) NEW_NODE(NODE_MASGN,l,0,r)
387
+ #define NEW_GASGN(v,val) NEW_NODE(NODE_GASGN,v,val,rb_global_entry(v))
388
+ #define NEW_LASGN(v,val) NEW_NODE(NODE_LASGN,v,val,0)
389
+ #define NEW_DASGN(v,val) NEW_NODE(NODE_DASGN,v,val,0)
390
+ #define NEW_DASGN_CURR(v,val) NEW_NODE(NODE_DASGN_CURR,v,val,0)
391
+ #define NEW_IASGN(v,val) NEW_NODE(NODE_IASGN,v,val,0)
392
+ #define NEW_IASGN2(v,val) NEW_NODE(NODE_IASGN2,v,val,0)
393
+ #define NEW_CDECL(v,val,path) NEW_NODE(NODE_CDECL,v,val,path)
394
+ #define NEW_CVASGN(v,val) NEW_NODE(NODE_CVASGN,v,val,0)
395
+ #define NEW_CVDECL(v,val) NEW_NODE(NODE_CVDECL,v,val,0)
396
+ #define NEW_OP_ASGN1(p,id,a) NEW_NODE(NODE_OP_ASGN1,p,id,a)
397
+ #define NEW_OP_ASGN2(r,t,i,o,val) NEW_NODE(NODE_OP_ASGN2,r,val,NEW_OP_ASGN22(i,o,t))
398
+ #define NEW_OP_ASGN22(i,o,t) NEW_NODE(NODE_OP_ASGN2,i,o,t)
399
+ #define NEW_OP_ASGN_OR(i,val) NEW_NODE(NODE_OP_ASGN_OR,i,val,0)
400
+ #define NEW_OP_ASGN_AND(i,val) NEW_NODE(NODE_OP_ASGN_AND,i,val,0)
401
+ #define NEW_OP_CDECL(v,op,val) NEW_NODE(NODE_OP_CDECL,v,val,op)
402
+ #define NEW_GVAR(v) NEW_NODE(NODE_GVAR,v,0,rb_global_entry(v))
403
+ #define NEW_LVAR(v) NEW_NODE(NODE_LVAR,v,0,0)
404
+ #define NEW_DVAR(v) NEW_NODE(NODE_DVAR,v,0,0)
405
+ #define NEW_IVAR(v) NEW_NODE(NODE_IVAR,v,0,0)
406
+ #define NEW_CONST(v) NEW_NODE(NODE_CONST,v,0,0)
407
+ #define NEW_CVAR(v) NEW_NODE(NODE_CVAR,v,0,0)
408
+ #define NEW_NTH_REF(n) NEW_NODE(NODE_NTH_REF,0,n,0)
409
+ #define NEW_BACK_REF(n) NEW_NODE(NODE_BACK_REF,0,n,0)
410
+ #define NEW_MATCH(c) NEW_NODE(NODE_MATCH,c,0,0)
411
+ #define NEW_MATCH2(n1,n2) NEW_NODE(NODE_MATCH2,n1,n2,0)
412
+ #define NEW_MATCH3(r,n2) NEW_NODE(NODE_MATCH3,r,n2,0)
413
+ #define NEW_LIT(l) NEW_NODE(NODE_LIT,l,0,0)
414
+ #define NEW_STR(s) NEW_NODE(NODE_STR,s,0,0)
415
+ #define NEW_DSTR(s) NEW_NODE(NODE_DSTR,s,1,0)
416
+ #define NEW_XSTR(s) NEW_NODE(NODE_XSTR,s,0,0)
417
+ #define NEW_DXSTR(s) NEW_NODE(NODE_DXSTR,s,0,0)
418
+ #define NEW_DSYM(s) NEW_NODE(NODE_DSYM,s,0,0)
419
+ #define NEW_EVSTR(n) NEW_NODE(NODE_EVSTR,0,(n),0)
420
+ #define NEW_CALL(r,m,a) NEW_NODE(NODE_CALL,r,m,a)
421
+ #define NEW_FCALL(m,a) NEW_NODE(NODE_FCALL,0,m,a)
422
+ #define NEW_VCALL(m) NEW_NODE(NODE_VCALL,0,m,0)
423
+ #define NEW_SUPER(a) NEW_NODE(NODE_SUPER,0,0,a)
424
+ #define NEW_ZSUPER() NEW_NODE(NODE_ZSUPER,0,0,0)
425
+ #define NEW_ARGS_AUX(r,b) NEW_NODE(NODE_ARGS_AUX,r,b,0)
426
+ #define NEW_OPT_ARG(i,v) NEW_NODE(NODE_OPT_ARG,i,v,0)
427
+ #define NEW_KW_ARG(i,v) NEW_NODE(NODE_KW_ARG,i,v,0)
428
+ #define NEW_POSTARG(i,v) NEW_NODE(NODE_POSTARG,i,v,0)
429
+ #define NEW_ARGSCAT(a,b) NEW_NODE(NODE_ARGSCAT,a,b,0)
430
+ #define NEW_ARGSPUSH(a,b) NEW_NODE(NODE_ARGSPUSH,a,b,0)
431
+ #define NEW_SPLAT(a) NEW_NODE(NODE_SPLAT,a,0,0)
432
+ #define NEW_TO_ARY(a) NEW_NODE(NODE_TO_ARY,a,0,0)
433
+ #define NEW_BLOCK_ARG(v) NEW_NODE(NODE_BLOCK_ARG,v,0,local_cnt(v))
434
+ #define NEW_BLOCK_PASS(b) NEW_NODE(NODE_BLOCK_PASS,0,b,0)
435
+ #define NEW_ALIAS(n,o) NEW_NODE(NODE_ALIAS,n,o,0)
436
+ #define NEW_VALIAS(n,o) NEW_NODE(NODE_VALIAS,n,o,0)
437
+ #define NEW_UNDEF(i) NEW_NODE(NODE_UNDEF,0,i,0)
438
+ #define NEW_CLASS(n,b,s) NEW_NODE(NODE_CLASS,n,NEW_SCOPE(0,b),(s))
439
+ #define NEW_SCLASS(r,b) NEW_NODE(NODE_SCLASS,r,NEW_SCOPE(0,b),0)
440
+ #define NEW_MODULE(n,b) NEW_NODE(NODE_MODULE,n,NEW_SCOPE(0,b),0)
441
+ #define NEW_COLON2(c,i) NEW_NODE(NODE_COLON2,c,i,0)
442
+ #define NEW_COLON3(i) NEW_NODE(NODE_COLON3,0,i,0)
443
+ #define NEW_DOT2(b,e) NEW_NODE(NODE_DOT2,b,e,0)
444
+ #define NEW_DOT3(b,e) NEW_NODE(NODE_DOT3,b,e,0)
445
+ #define NEW_SELF() NEW_NODE(NODE_SELF,0,0,0)
446
+ #define NEW_NIL() NEW_NODE(NODE_NIL,0,0,0)
447
+ #define NEW_TRUE() NEW_NODE(NODE_TRUE,0,0,0)
448
+ #define NEW_FALSE() NEW_NODE(NODE_FALSE,0,0,0)
449
+ #define NEW_ERRINFO() NEW_NODE(NODE_ERRINFO,0,0,0)
450
+ #define NEW_DEFINED(e) NEW_NODE(NODE_DEFINED,e,0,0)
451
+ #define NEW_PREEXE(b) NEW_SCOPE(b)
452
+ #define NEW_POSTEXE(b) NEW_NODE(NODE_POSTEXE,0,b,0)
453
+ #define NEW_BMETHOD(b) NEW_NODE(NODE_BMETHOD,0,0,b)
454
+ #define NEW_ATTRASGN(r,m,a) NEW_NODE(NODE_ATTRASGN,r,m,a)
455
+ #define NEW_PRELUDE(p,b,o) NEW_NODE(NODE_PRELUDE,p,b,o)
456
+
457
+ RUBY_SYMBOL_EXPORT_BEGIN
458
+
459
+ VALUE rb_parser_new(void);
460
+ VALUE rb_parser_end_seen_p(VALUE);
461
+ VALUE rb_parser_encoding(VALUE);
462
+ VALUE rb_parser_get_yydebug(VALUE);
463
+ VALUE rb_parser_set_yydebug(VALUE, VALUE);
464
+ VALUE rb_parser_dump_tree(NODE *node, int comment);
465
+ NODE *rb_parser_append_print(VALUE, NODE *);
466
+ NODE *rb_parser_while_loop(VALUE, NODE *, int, int);
467
+
468
+ NODE *rb_parser_compile_cstr(VALUE, const char*, const char*, int, int);
469
+ NODE *rb_parser_compile_string(VALUE, const char*, VALUE, int);
470
+ NODE *rb_parser_compile_file(VALUE, const char*, VALUE, int);
471
+ NODE *rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
472
+ NODE *rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
473
+
474
+ NODE *rb_compile_cstr(const char*, const char*, int, int);
475
+ NODE *rb_compile_string(const char*, VALUE, int);
476
+ NODE *rb_compile_file(const char*, VALUE, int);
477
+
478
+ NODE *rb_node_newnode(enum node_type,VALUE,VALUE,VALUE);
479
+ NODE *rb_node_newnode_longlife(enum node_type,VALUE,VALUE,VALUE);
480
+ void rb_gc_free_node(VALUE obj);
481
+ size_t rb_node_memsize(VALUE obj);
482
+ VALUE rb_gc_mark_node(NODE *obj);
483
+
484
+ const struct kwtable *rb_reserved_word(const char *, unsigned int);
485
+
486
+ struct rb_args_info {
487
+ NODE *pre_init;
488
+ NODE *post_init;
489
+
490
+ int pre_args_num; /* count of mandatory pre-arguments */
491
+ int post_args_num; /* count of mandatory post-arguments */
492
+
493
+ ID first_post_arg;
494
+
495
+ ID rest_arg;
496
+ ID block_arg;
497
+
498
+ NODE *kw_args;
499
+ NODE *kw_rest_arg;
500
+
501
+ NODE *opt_args;
502
+ };
503
+
504
+ struct parser_params;
505
+ void *rb_parser_malloc(struct parser_params *, size_t);
506
+ void *rb_parser_realloc(struct parser_params *, void *, size_t);
507
+ void *rb_parser_calloc(struct parser_params *, size_t, size_t);
508
+ void rb_parser_free(struct parser_params *, void *);
509
+ void rb_parser_printf(struct parser_params *parser, const char *fmt, ...);
510
+
511
+ RUBY_SYMBOL_EXPORT_END
512
+
513
+ #if defined(__cplusplus)
514
+ #if 0
515
+ { /* satisfy cc-mode */
516
+ #endif
517
+ } /* extern "C" { */
518
+ #endif
519
+
520
+ #endif /* RUBY_NODE_H */