2007-08-24 11:26:28 -04:00
|
|
|
|
|
|
|
prelude, outfile = *ARGV
|
|
|
|
|
2007-08-24 19:49:19 -04:00
|
|
|
lines = File.readlines(prelude).map{|line|
|
|
|
|
line.dump
|
2007-08-24 11:26:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
open(outfile, 'w'){|f|
|
2007-08-24 21:20:30 -04:00
|
|
|
f.puts <<EOS__, <<'EOS__'
|
2007-08-24 11:26:28 -04:00
|
|
|
|
|
|
|
#include "ruby/ruby.h"
|
2007-08-24 19:49:19 -04:00
|
|
|
#include "vm_core.h"
|
|
|
|
|
2007-08-24 21:20:30 -04:00
|
|
|
static const char prelude_name[] = "#{File.basename(prelude)}";
|
|
|
|
static const char prelude_code[] =
|
2007-08-24 11:26:28 -04:00
|
|
|
#{lines.join("\n")}
|
|
|
|
;
|
2007-08-24 21:20:30 -04:00
|
|
|
EOS__
|
|
|
|
|
2007-08-24 11:26:28 -04:00
|
|
|
void
|
|
|
|
Init_prelude(void)
|
|
|
|
{
|
|
|
|
rb_iseq_eval(rb_iseq_compile(
|
2007-08-24 21:20:30 -04:00
|
|
|
rb_str_new(prelude_code, sizeof(prelude_code) - 1),
|
|
|
|
rb_str_new(prelude_name, sizeof(prelude_name) - 1),
|
|
|
|
INT2FIX(1)));
|
2007-08-24 19:49:19 -04:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
printf("%s\n", prelude_code);
|
|
|
|
#endif
|
2007-08-24 11:26:28 -04:00
|
|
|
}
|
|
|
|
EOS__
|
|
|
|
}
|
|
|
|
|