node-marshal 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 37790a2feee8e4d9869f054217f7f5619b34f50a
4
+ data.tar.gz: 4c5d0348106b37071045ec5da275d6f66f9420d2
5
+ SHA512:
6
+ metadata.gz: 34b5a2b79293e3ce4ee8be7999f8d41171147188b70e508193a153ab01bf193babdb63ed815ae5a187dd944b9faa0eccb58d3398061426140bb5d03ed915b4cb
7
+ data.tar.gz: 49d63f4879503ee1fd9b756044013c04792721a20dc66e8bb14c6f6af9b6c88512c43356eeb75a26bf5df5f58bdc72f4bfaccae5823816a5cdf2b65671c9b8d7
@@ -0,0 +1,18 @@
1
+ == node-marshal
2
+
3
+ This gem is designed for transformation of Ruby source code (eiher in the form of files or strings) to the
4
+ Ruby nodes (syntax trees) used by Ruby MRI internals. Obtained nodes can be serialized to the platform-dependent
5
+ binary or ASCII strings and restored and launched from serialized format. Such kind of transformation is
6
+ irreversible and can be used for source code protection; the similar principle is used by RubyEncoder commercial
7
+ software.
8
+
9
+ The key features of node-marshal gem:
10
+ - Irreversible conversion of a source code to the Ruby node (abstract syntax tree)
11
+ - Ruby 1.9.3 and 2.2.x support (only MRI)
12
+ - Active usage of Ruby internals (mainly AST) and Ruby standard library (Marshal and Zlib)
13
+ - Set of tests for easy addition of new Ruby versions
14
+ - Result of compilation depends on Ruby version and used platform (x86, x64 etc.)
15
+ - 2-clause BSD license suitable for creation of custom source code protection system
16
+
17
+ Changelog:
18
+ - 04.MAY.2015 - 0.1.1 - first public version
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/ruby
2
+ require_relative '../lib/node-marshal.rb'
3
+
4
+ help = <<-EOS
5
+ Ruby source files compiler. It is based on NodeMarshal class.
6
+ from NodeDump gem. Source code is transformed to the Ruby node
7
+ (syntax tree) serialized into ASCII string. Such transformation
8
+ is based on Ruby internal syntax tree, irreversible and can
9
+ be used for code obfuscation.
10
+
11
+ (C) 2015 Alexey Voskov. License: 2-clause BSD.
12
+
13
+ Usage:
14
+ noderbc inpfile outfile
15
+
16
+ inpfile -- Name of input Ruby script (with extension)
17
+ outfile -- Name of output Ruby (with extension)
18
+ EOS
19
+
20
+ if ARGV.length != 2
21
+ puts help
22
+ else
23
+ inpfile = ARGV[0]
24
+ outfile = ARGV[1]
25
+ raise 'inpfile and outfile cannot be equal' if inpfile == outfile
26
+ NodeMarshal.compile_rb_file(outfile, inpfile)
27
+ end
@@ -0,0 +1 @@
1
+ @ruby noderbc %*
@@ -0,0 +1,23 @@
1
+ Copyright (C) 2015 Alexey Voskov. All rights reserved.
2
+ Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions
6
+ are met:
7
+ 1. Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
+ SUCH DAMAGE.
@@ -0,0 +1,190 @@
1
+ /*
2
+ * Implementation of own version of BASE85 binary data encoding
3
+ * adapted for the usage inside Ruby source code (i.e. without
4
+ * such symbols as \ " # { } '
5
+ *
6
+ * Format of the output stream:
7
+ * 1) First byte: number of bytes in the last chunk: from 0 to 3
8
+ * (0 means that the last chunk contains 4 bytes, i.e. everything
9
+ * is aligned). See val_to_char array for the used alphabet
10
+ * 2) big-endian 5-byte numbers (base 85)
11
+ * 3) empty string: arbitrary two bytes
12
+ *
13
+ * (C) 2015 Alexey Voskov
14
+ * License: 2-clause BSD
15
+ */
16
+ #include <stdio.h>
17
+ #include <stdlib.h>
18
+ #include <inttypes.h>
19
+ #include <ruby.h>
20
+ #include <ruby/version.h>
21
+
22
+ #define BASE85R_STR_WIDTH 14 // Number of 5-byte groups in the string (12 for 60-byte string)
23
+
24
+ #define D0_VAL 1 // 85**0
25
+ #define D1_VAL 85 // 85**1
26
+ #define D2_VAL 7225 // 85**2
27
+ #define D3_VAL 614125 // 85**3
28
+ #define D4_VAL 52200625 // 85**4
29
+
30
+ static int di_val[5] = {D4_VAL, D3_VAL, D2_VAL, D1_VAL, D0_VAL};
31
+
32
+
33
+ /* Modified BASE85 digits */
34
+ static const char val_to_char[86] = // ASCIIZ string
35
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
36
+ "abcdefghijklmnopqrstuvwxyz"
37
+ "0123456789"
38
+ "!$%&()*-./"
39
+ ":;<=>?@[]^"
40
+ ",_|";
41
+
42
+ static int char_to_val[128];
43
+
44
+
45
+ /* Initializes internal tables that are required
46
+ for recoding */
47
+ void base85r_init_tables()
48
+ {
49
+ int i;
50
+ for (i = 0; i < 128; i++)
51
+ char_to_val[i] = -1;
52
+
53
+
54
+ for (i = 0; i < 85; i++)
55
+ {
56
+ if (char_to_val[(int) val_to_char[i]] != -1)
57
+ rb_raise(rb_eArgError, "Internal error");
58
+ char_to_val[(int) val_to_char[i]] = i;
59
+ }
60
+
61
+ for (i = 0; i < 85; i++)
62
+ if (char_to_val[(int) val_to_char[i]] != i)
63
+ rb_raise(rb_eArgError, "Internal error");
64
+ }
65
+
66
+
67
+ /* Calculate length of buffer for base85 encoding */
68
+ static int base85_encode_buf_len(int len)
69
+ {
70
+ // Calculate aligned (32-bit alignment) size of the buffer
71
+ int buf_len = ((len >> 2) << 2);
72
+ if (len % 4) buf_len += 4;
73
+ // Calculate size of the output buffer
74
+ buf_len = (buf_len * 5) / 4;
75
+ buf_len = (buf_len * 105) / 100;
76
+ buf_len += 32;
77
+ // Return buffer size
78
+ return buf_len;
79
+ }
80
+
81
+ /* Encode string to modified BASE85 ASCII.
82
+ Call base85_init_tables before using of this function */
83
+ VALUE base85r_encode(VALUE input)
84
+ {
85
+ VALUE output;
86
+ int inp_len, out_len, out_buf_len;
87
+ int pos, outpos;
88
+ unsigned int val;
89
+ unsigned char *outptr, *inptr;
90
+ int i;
91
+ // Check input data type and allocate string
92
+ if (TYPE(input) != T_STRING)
93
+ rb_raise(rb_eArgError, "base85r_encode: input must be a string");
94
+ inp_len = RSTRING_LEN(input);
95
+ out_buf_len = base85_encode_buf_len(inp_len);
96
+ output = rb_str_new(NULL, out_buf_len);
97
+ // Begin conversion
98
+ outpos = 0;
99
+ outptr = (unsigned char *) RSTRING_PTR(output);
100
+ inptr = (unsigned char *) RSTRING_PTR(input);
101
+ outptr[outpos++] = 32;
102
+ outptr[outpos++] = val_to_char[inp_len % 4];
103
+ out_len = 2;
104
+ for (pos = 0; pos < inp_len; )
105
+ {
106
+ // Get four bytes
107
+ val = 0;
108
+ for (i = 24; i >= 0; i -= 8)
109
+ if (pos < inp_len) val |= inptr[pos++] << i;
110
+ // And transform them to five bytes
111
+ for (i = 0; i < 5; i++)
112
+ {
113
+ int digit = (val / di_val[i]) % 85;
114
+ char sym = val_to_char[digit];
115
+ outptr[outpos++] = sym;
116
+ }
117
+ out_len += 5;
118
+ // Newline addition
119
+ if (pos % (4 * BASE85R_STR_WIDTH) == 0)
120
+ {
121
+ out_len += 2;
122
+ outptr[outpos++] = 10;
123
+ outptr[outpos++]= 32;
124
+ }
125
+ }
126
+ // Check the state of memory
127
+ if (outpos >= out_buf_len)
128
+ rb_raise(rb_eArgError, "base85r_encode: internal memory error");
129
+ // Truncate the empty "tail" of the buffer and return the string
130
+ return rb_str_resize(output, out_len);
131
+ }
132
+
133
+
134
+ /* Decode string in modified BASE85 ASCII format.
135
+ Call base85_init_tables before using of this function */
136
+ VALUE base85r_decode(VALUE input)
137
+ {
138
+ int inp_len, out_len, pos, shift;
139
+ unsigned int val = 0;
140
+ VALUE output;
141
+ unsigned char *inptr, *outptr;
142
+ int tail_len, i;
143
+ // Check input data type and allocate string
144
+ if (TYPE(input) != T_STRING)
145
+ rb_raise(rb_eArgError, "base85r_decode: input must be a string");
146
+ inp_len = RSTRING_LEN(input);
147
+ if (inp_len < 6 && inp_len != 2)
148
+ { // String with 1 or more symbols
149
+ rb_raise(rb_eArgError, "base85r_decode: input string is too short");
150
+ }
151
+ output = rb_str_new(NULL, inp_len);
152
+ // Begin conversion
153
+ inptr = (unsigned char *) RSTRING_PTR(input);
154
+ outptr = (unsigned char *) RSTRING_PTR(output);
155
+ out_len = 0;
156
+ tail_len = -1;
157
+ shift = 0;
158
+ val = 0;
159
+ for (pos = 0; pos < inp_len; pos++)
160
+ {
161
+ int digit = char_to_val[(int) inptr[pos]];
162
+ if (digit != -1)
163
+ {
164
+ if (tail_len == -1)
165
+ {
166
+ tail_len = digit;
167
+ if (tail_len > 4)
168
+ rb_raise(rb_eArgError, "base85r_decode: input string is corrupted");
169
+ continue;
170
+ }
171
+ val += digit * di_val[shift++];
172
+ if (shift == 5)
173
+ {
174
+ for (i = 24; i >= 0; i -= 8)
175
+ *outptr++ = (val >> i) & 0xFF;
176
+ shift = 0; val = 0;
177
+ out_len += 4;
178
+ }
179
+ }
180
+ }
181
+ // Check if the byte sequence was valid
182
+ if (shift != 0)
183
+ rb_raise(rb_eArgError, "base85r_decode: input string is corrupted");
184
+ // Take into account unaligned "tail"
185
+ if (tail_len != 0)
186
+ {
187
+ out_len -= (4 - tail_len);
188
+ }
189
+ return rb_str_resize(output, out_len);
190
+ }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/ruby
2
+ require 'mkmf'
3
+ create_makefile('nodemarshal')
@@ -0,0 +1 @@
1
+ Directory for the object files for static library assembling.
@@ -0,0 +1,312 @@
1
+ /*
2
+ * Simpilfied node.h file from Ruby 1.9.3 source code
3
+ * Copyright (C) 1993-2007 Yukihiro Matsumoto
4
+ */
5
+
6
+ #ifndef RUBY_NODE_H
7
+ #define RUBY_NODE_H 1
8
+
9
+ #if defined(__cplusplus)
10
+ extern "C" {
11
+ #if 0
12
+ } /* satisfy cc-mode */
13
+ #endif
14
+ #endif
15
+
16
+ enum node_type {
17
+ NODE_SCOPE,
18
+ #define NODE_SCOPE NODE_SCOPE
19
+ NODE_BLOCK,
20
+ #define NODE_BLOCK NODE_BLOCK
21
+ NODE_IF,
22
+ #define NODE_IF NODE_IF
23
+ NODE_CASE,
24
+ #define NODE_CASE NODE_CASE
25
+ NODE_WHEN,
26
+ #define NODE_WHEN NODE_WHEN
27
+ NODE_OPT_N,
28
+ #define NODE_OPT_N NODE_OPT_N
29
+ NODE_WHILE,
30
+ #define NODE_WHILE NODE_WHILE
31
+ NODE_UNTIL,
32
+ #define NODE_UNTIL NODE_UNTIL
33
+ NODE_ITER,
34
+ #define NODE_ITER NODE_ITER
35
+ NODE_FOR,
36
+ #define NODE_FOR NODE_FOR
37
+ NODE_BREAK,
38
+ #define NODE_BREAK NODE_BREAK
39
+ NODE_NEXT,
40
+ #define NODE_NEXT NODE_NEXT
41
+ NODE_REDO,
42
+ #define NODE_REDO NODE_REDO
43
+ NODE_RETRY,
44
+ #define NODE_RETRY NODE_RETRY
45
+ NODE_BEGIN,
46
+ #define NODE_BEGIN NODE_BEGIN
47
+ NODE_RESCUE,
48
+ #define NODE_RESCUE NODE_RESCUE
49
+ NODE_RESBODY,
50
+ #define NODE_RESBODY NODE_RESBODY
51
+ NODE_ENSURE,
52
+ #define NODE_ENSURE NODE_ENSURE
53
+ NODE_AND,
54
+ #define NODE_AND NODE_AND
55
+ NODE_OR,
56
+ #define NODE_OR NODE_OR
57
+ NODE_MASGN,
58
+ #define NODE_MASGN NODE_MASGN
59
+ NODE_LASGN,
60
+ #define NODE_LASGN NODE_LASGN
61
+ NODE_DASGN,
62
+ #define NODE_DASGN NODE_DASGN
63
+ NODE_DASGN_CURR,
64
+ #define NODE_DASGN_CURR NODE_DASGN_CURR
65
+ NODE_GASGN,
66
+ #define NODE_GASGN NODE_GASGN
67
+ NODE_IASGN,
68
+ #define NODE_IASGN NODE_IASGN
69
+ NODE_IASGN2,
70
+ #define NODE_IASGN2 NODE_IASGN2
71
+ NODE_CDECL,
72
+ #define NODE_CDECL NODE_CDECL
73
+ NODE_CVASGN,
74
+ #define NODE_CVASGN NODE_CVASGN
75
+ NODE_CVDECL,
76
+ #define NODE_CVDECL NODE_CVDECL
77
+ NODE_OP_ASGN1,
78
+ #define NODE_OP_ASGN1 NODE_OP_ASGN1
79
+ NODE_OP_ASGN2,
80
+ #define NODE_OP_ASGN2 NODE_OP_ASGN2
81
+ NODE_OP_ASGN_AND,
82
+ #define NODE_OP_ASGN_AND NODE_OP_ASGN_AND
83
+ NODE_OP_ASGN_OR,
84
+ #define NODE_OP_ASGN_OR NODE_OP_ASGN_OR
85
+ NODE_CALL,
86
+ #define NODE_CALL NODE_CALL
87
+ NODE_FCALL,
88
+ #define NODE_FCALL NODE_FCALL
89
+ NODE_VCALL,
90
+ #define NODE_VCALL NODE_VCALL
91
+ NODE_SUPER,
92
+ #define NODE_SUPER NODE_SUPER
93
+ NODE_ZSUPER,
94
+ #define NODE_ZSUPER NODE_ZSUPER
95
+ NODE_ARRAY,
96
+ #define NODE_ARRAY NODE_ARRAY
97
+ NODE_ZARRAY,
98
+ #define NODE_ZARRAY NODE_ZARRAY
99
+ NODE_VALUES,
100
+ #define NODE_VALUES NODE_VALUES
101
+ NODE_HASH,
102
+ #define NODE_HASH NODE_HASH
103
+ NODE_RETURN,
104
+ #define NODE_RETURN NODE_RETURN
105
+ NODE_YIELD,
106
+ #define NODE_YIELD NODE_YIELD
107
+ NODE_LVAR,
108
+ #define NODE_LVAR NODE_LVAR
109
+ NODE_DVAR,
110
+ #define NODE_DVAR NODE_DVAR
111
+ NODE_GVAR,
112
+ #define NODE_GVAR NODE_GVAR
113
+ NODE_IVAR,
114
+ #define NODE_IVAR NODE_IVAR
115
+ NODE_CONST,
116
+ #define NODE_CONST NODE_CONST
117
+ NODE_CVAR,
118
+ #define NODE_CVAR NODE_CVAR
119
+ NODE_NTH_REF,
120
+ #define NODE_NTH_REF NODE_NTH_REF
121
+ NODE_BACK_REF,
122
+ #define NODE_BACK_REF NODE_BACK_REF
123
+ NODE_MATCH,
124
+ #define NODE_MATCH NODE_MATCH
125
+ NODE_MATCH2,
126
+ #define NODE_MATCH2 NODE_MATCH2
127
+ NODE_MATCH3,
128
+ #define NODE_MATCH3 NODE_MATCH3
129
+ NODE_LIT,
130
+ #define NODE_LIT NODE_LIT
131
+ NODE_STR,
132
+ #define NODE_STR NODE_STR
133
+ NODE_DSTR,
134
+ #define NODE_DSTR NODE_DSTR
135
+ NODE_XSTR,
136
+ #define NODE_XSTR NODE_XSTR
137
+ NODE_DXSTR,
138
+ #define NODE_DXSTR NODE_DXSTR
139
+ NODE_EVSTR,
140
+ #define NODE_EVSTR NODE_EVSTR
141
+ NODE_DREGX,
142
+ #define NODE_DREGX NODE_DREGX
143
+ NODE_DREGX_ONCE,
144
+ #define NODE_DREGX_ONCE NODE_DREGX_ONCE
145
+ NODE_ARGS,
146
+ #define NODE_ARGS NODE_ARGS
147
+ NODE_ARGS_AUX,
148
+ #define NODE_ARGS_AUX NODE_ARGS_AUX
149
+ NODE_OPT_ARG,
150
+ #define NODE_OPT_ARG NODE_OPT_ARG
151
+ NODE_POSTARG,
152
+ #define NODE_POSTARG NODE_POSTARG
153
+ NODE_ARGSCAT,
154
+ #define NODE_ARGSCAT NODE_ARGSCAT
155
+ NODE_ARGSPUSH,
156
+ #define NODE_ARGSPUSH NODE_ARGSPUSH
157
+ NODE_SPLAT,
158
+ #define NODE_SPLAT NODE_SPLAT
159
+ NODE_TO_ARY,
160
+ #define NODE_TO_ARY NODE_TO_ARY
161
+ NODE_BLOCK_ARG,
162
+ #define NODE_BLOCK_ARG NODE_BLOCK_ARG
163
+ NODE_BLOCK_PASS,
164
+ #define NODE_BLOCK_PASS NODE_BLOCK_PASS
165
+ NODE_DEFN,
166
+ #define NODE_DEFN NODE_DEFN
167
+ NODE_DEFS,
168
+ #define NODE_DEFS NODE_DEFS
169
+ NODE_ALIAS,
170
+ #define NODE_ALIAS NODE_ALIAS
171
+ NODE_VALIAS,
172
+ #define NODE_VALIAS NODE_VALIAS
173
+ NODE_UNDEF,
174
+ #define NODE_UNDEF NODE_UNDEF
175
+ NODE_CLASS,
176
+ #define NODE_CLASS NODE_CLASS
177
+ NODE_MODULE,
178
+ #define NODE_MODULE NODE_MODULE
179
+ NODE_SCLASS,
180
+ #define NODE_SCLASS NODE_SCLASS
181
+ NODE_COLON2,
182
+ #define NODE_COLON2 NODE_COLON2
183
+ NODE_COLON3,
184
+ #define NODE_COLON3 NODE_COLON3
185
+ NODE_DOT2,
186
+ #define NODE_DOT2 NODE_DOT2
187
+ NODE_DOT3,
188
+ #define NODE_DOT3 NODE_DOT3
189
+ NODE_FLIP2,
190
+ #define NODE_FLIP2 NODE_FLIP2
191
+ NODE_FLIP3,
192
+ #define NODE_FLIP3 NODE_FLIP3
193
+ NODE_SELF,
194
+ #define NODE_SELF NODE_SELF
195
+ NODE_NIL,
196
+ #define NODE_NIL NODE_NIL
197
+ NODE_TRUE,
198
+ #define NODE_TRUE NODE_TRUE
199
+ NODE_FALSE,
200
+ #define NODE_FALSE NODE_FALSE
201
+ NODE_ERRINFO,
202
+ #define NODE_ERRINFO NODE_ERRINFO
203
+ NODE_DEFINED,
204
+ #define NODE_DEFINED NODE_DEFINED
205
+ NODE_POSTEXE,
206
+ #define NODE_POSTEXE NODE_POSTEXE
207
+ NODE_ALLOCA,
208
+ #define NODE_ALLOCA NODE_ALLOCA
209
+ NODE_BMETHOD,
210
+ #define NODE_BMETHOD NODE_BMETHOD
211
+ NODE_MEMO,
212
+ #define NODE_MEMO NODE_MEMO
213
+ NODE_IFUNC,
214
+ #define NODE_IFUNC NODE_IFUNC
215
+ NODE_DSYM,
216
+ #define NODE_DSYM NODE_DSYM
217
+ NODE_ATTRASGN,
218
+ #define NODE_ATTRASGN NODE_ATTRASGN
219
+ NODE_PRELUDE,
220
+ #define NODE_PRELUDE NODE_PRELUDE
221
+ NODE_LAMBDA,
222
+ #define NODE_LAMBDA NODE_LAMBDA
223
+ NODE_OPTBLOCK,
224
+ #define NODE_OPTBLOCK NODE_OPTBLOCK
225
+ NODE_LAST
226
+ #define NODE_LAST NODE_LAST
227
+ };
228
+
229
+ typedef struct RNode {
230
+ VALUE flags;
231
+ VALUE nd_reserved; /* ex nd_file */
232
+ union {
233
+ struct RNode *node;
234
+ ID id;
235
+ VALUE value;
236
+ VALUE (*cfunc)(ANYARGS);
237
+ ID *tbl;
238
+ } u1;
239
+ union {
240
+ struct RNode *node;
241
+ ID id;
242
+ long argc;
243
+ VALUE value;
244
+ } u2;
245
+ union {
246
+ struct RNode *node;
247
+ ID id;
248
+ long state;
249
+ struct rb_global_entry *entry;
250
+ long cnt;
251
+ VALUE value;
252
+ } u3;
253
+ } NODE;
254
+
255
+ #define RNODE(obj) (R_CAST(RNode)(obj))
256
+
257
+ /* 0..4:T_TYPES, 5:FL_MARK, 6:reserved, 7:NODE_FL_NEWLINE */
258
+ #define NODE_FL_NEWLINE (((VALUE)1)<<7)
259
+ #define NODE_FL_CREF_PUSHED_BY_EVAL NODE_FL_NEWLINE
260
+
261
+ #define NODE_TYPESHIFT 8
262
+ #define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT)
263
+
264
+ #define nd_type(n) ((int) (((RNODE(n))->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT))
265
+ #define nd_set_type(n,t) \
266
+ RNODE(n)->flags=((RNODE(n)->flags&~NODE_TYPEMASK)|((((unsigned long)(t))<<NODE_TYPESHIFT)&NODE_TYPEMASK))
267
+
268
+ #define NODE_LSHIFT (NODE_TYPESHIFT+7)
269
+ #define NODE_LMASK (((SIGNED_VALUE)1<<(sizeof(VALUE)*CHAR_BIT-NODE_LSHIFT))-1)
270
+ #define nd_line(n) (int)(RNODE(n)->flags>>NODE_LSHIFT)
271
+ #define nd_set_line(n,l) \
272
+ RNODE(n)->flags=((RNODE(n)->flags&~(-1<<NODE_LSHIFT))|(((l)&NODE_LMASK)<<NODE_LSHIFT))
273
+
274
+ #define NEW_NODE(t,a0,a1,a2) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2))
275
+
276
+
277
+ #if defined __GNUC__ && __GNUC__ >= 4
278
+ #pragma GCC visibility push(default)
279
+ #endif
280
+
281
+ VALUE rb_parser_dump_tree(NODE *node, int comment);
282
+
283
+ NODE *rb_compile_cstr(const char*, const char*, int, int);
284
+ NODE *rb_compile_string(const char*, VALUE, int);
285
+ NODE *rb_compile_file(const char*, VALUE, int);
286
+
287
+ NODE *rb_node_newnode(enum node_type,VALUE,VALUE,VALUE);
288
+ NODE *rb_node_newnode_longlife(enum node_type,VALUE,VALUE,VALUE);
289
+
290
+ struct rb_global_entry {
291
+ struct rb_global_variable *var;
292
+ ID id;
293
+ };
294
+
295
+ struct rb_global_entry *rb_global_entry(ID);
296
+ VALUE rb_gvar_get(struct rb_global_entry *);
297
+ VALUE rb_gvar_set(struct rb_global_entry *, VALUE);
298
+ VALUE rb_gvar_defined(struct rb_global_entry *);
299
+ const struct kwtable *rb_reserved_word(const char *, unsigned int);
300
+
301
+ #if defined __GNUC__ && __GNUC__ >= 4
302
+ #pragma GCC visibility pop
303
+ #endif
304
+
305
+ #if defined(__cplusplus)
306
+ #if 0
307
+ { /* satisfy cc-mode */
308
+ #endif
309
+ } /* extern "C" { */
310
+ #endif
311
+
312
+ #endif /* RUBY_NODE_H */