summaryrefslogtreecommitdiff
path: root/tool/compile_prelude.rb
blob: 13ccb8aceda39ec79b652164a7938d4b1444689c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

prelude, outfile = *ARGV
lines = []

File.readlines(prelude).each{|line|
  lines << "#{line.dump}"
}

open(outfile, 'w'){|f|
f.puts <<EOS__

#include "ruby/ruby.h"
static const char *prelude_code = 
#{lines.join("\n")}
;
void
Init_prelude(void)
{
  rb_iseq_eval(rb_iseq_compile(
    rb_str_new2(prelude_code),
    rb_str_new2("prelude.rb"), INT2FIX(1)));
}
EOS__
}