debase-ruby_core_source 0.8.0 → 0.8.1

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