Top Level Namespace
Defined Under Namespace
Modules: Melbourne, Rubinius
Classes: File, String
Instance Method Summary
collapse
Instance Method Details
#add_lib(name) ⇒ Object
4
5
6
7
|
# File 'ext/melbourne/extconf.rb', line 4
def add_lib(name)
i, lib = dir_config(name)
$libs << " #{lib}/lib#{name}.a "
end
|
#write_node_types(list, version) ⇒ Object
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
# File 'ext/melbourne/node_types.rb', line 232
def write_node_types(list, version)
File.open("node_types#{version}.cpp", "wb") do |f|
f.puts <<EOF
/* This file is generated by node_types.rb. Do not edit. */
#include "node_types#{version}.hpp"
#include <stdio.h>
namespace melbourne {
namespace grammar#{version} {
static const char node_types[] = {
EOF
indexes = [0]
list.each do |type|
f.puts(" \"#{type}\\0\"")
indexes.push indexes.last + type.size + 1
end
f.puts(" };")
f.puts
f.puts(" static const unsigned short node_types_offsets[] = {")
f.puts indexes.map { |i| " #{i}" }.join(",\n")
f.puts <<EOF
};
const char *get_node_type_string(enum node_type node) {
if(node < #{list.size}) {
return node_types + node_types_offsets[node];
} else {
#define NODE_STRING_MESSAGE_LEN 20
static char msg[NODE_STRING_MESSAGE_LEN];
snprintf(msg, NODE_STRING_MESSAGE_LEN, "unknown node type: %d", node);
return msg;
}
}
}; // namespace grammar#{version}
}; // namespace melbourne
EOF
end
File.open("node_types#{version}.hpp", "wb") do |f|
f.puts <<EOF
#ifndef MEL_NODE_TYPES#{version}_HPP
#define MEL_NODE_TYPES#{version}_HPP
/* This file is generated by node_types.rb. Do not edit. */
namespace melbourne {
namespace grammar#{version} {
enum node_type {
EOF
f.puts list.map { |x| " NODE_#{x.upcase}" }.join(",\n")
f.puts <<EOF
};
const char *get_node_type_string(enum node_type nt);
}; // namespace grammar#{version}
}; // namespace melbourne
#endif
EOF
end
end
|