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 "/* This file is generated by node_types.rb. Do not edit. */\n\n#include \"node_types\#{version}.hpp\"\n\n#include <stdio.h>\n\nnamespace melbourne {\n namespace grammar\#{version} {\n static const char node_types[] = {\n"
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 " };\n\n const char *get_node_type_string(enum node_type node) {\n if(node < \#{list.size}) {\n return node_types + node_types_offsets[node];\n } else {\n#define NODE_STRING_MESSAGE_LEN 20\n static char msg[NODE_STRING_MESSAGE_LEN];\n snprintf(msg, NODE_STRING_MESSAGE_LEN, \"unknown node type: %d\", node);\n return msg;\n }\n }\n }; // namespace grammar\#{version}\n}; // namespace melbourne\n"
end
File.open("node_types#{version}.hpp", "wb") do |f|
f.puts "#ifndef MEL_NODE_TYPES\#{version}_HPP\n#define MEL_NODE_TYPES\#{version}_HPP\n/* This file is generated by node_types.rb. Do not edit. */\n\nnamespace melbourne {\n namespace grammar\#{version} {\n enum node_type {\n"
f.puts list.map { |x| " NODE_#{x.upcase}" }.join(",\n")
f.puts " };\n\n const char *get_node_type_string(enum node_type nt);\n\n }; // namespace grammar\#{version}\n}; // namespace melbourne\n\n#endif\n"
end
end
|