summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--common.mk2
-rw-r--r--tool/compile_prelude.rb35
3 files changed, 22 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index bc567f5..a09b48b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Dec 21 09:26:48 2007 Tanaka Akira <akr@fsij.org>
+
+ * tool/compile_prelude.rb: use erb.
+
Fri Dec 21 08:07:35 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* enumerator.c (enumerator_next): should call next_init() if fiber
diff --git a/common.mk b/common.mk
index 48119a0..1971641 100644
--- a/common.mk
+++ b/common.mk
@@ -648,7 +648,7 @@ miniprelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb
$(BASERUBY) -I$(srcdir) $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $@
prelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(srcdir)/gem_prelude.rb $(RBCONFIG)
- $(MINIRUBY) -I$(srcdir) -rrbconfig $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(srcdir)/gem_prelude.rb $@
+ $(MINIRUBY) -I$(srcdir) -I$(srcdir)/lib -rrbconfig $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(srcdir)/gem_prelude.rb $@
prereq: incs {$(VPATH)}parse.c $(srcdir)/ext/ripper/ripper.c {$(VPATH)}miniprelude.c
diff --git a/tool/compile_prelude.rb b/tool/compile_prelude.rb
index 4a2c2ea..60d56fb 100644
--- a/tool/compile_prelude.rb
+++ b/tool/compile_prelude.rb
@@ -56,36 +56,35 @@ lines_list = preludes.map {|filename|
[setup_lines, lines]
}
-require 'tool/serb'
+require 'erb'
-tmp = ''
-eval(serb(<<'EOS', 'tmp'))
+tmp = ERB.new(<<'EOS', nil, '%').result(binding)
#include "ruby/ruby.h"
#include "vm_core.h"
-! preludes.zip(lines_list).each_with_index {|(prelude, (setup_lines, lines)), i|
-static const char prelude_name<%i%>[] = <%c_esc(File.basename(prelude))%>;
-static const char prelude_code<%i%>[] =
-! (setup_lines+lines).each {|line|
-<%line%>
-! }
+% preludes.zip(lines_list).each_with_index {|(prelude, (setup_lines, lines)), i|
+static const char prelude_name<%=i%>[] = <%=c_esc(File.basename(prelude))%>;
+static const char prelude_code<%=i%>[] =
+% (setup_lines+lines).each {|line|
+<%=line%>
+% }
;
-! }
+% }
void
Init_prelude(void)
{
-! lines_list.each_with_index {|(setup_lines, lines), i|
+% lines_list.each_with_index {|(setup_lines, lines), i|
rb_iseq_eval(rb_iseq_compile(
- rb_str_new(prelude_code<%i%>, sizeof(prelude_code<%i%>) - 1),
- rb_str_new(prelude_name<%i%>, sizeof(prelude_name<%i%>) - 1),
- INT2FIX(<%1-setup_lines.length%>)));
+ rb_str_new(prelude_code<%=i%>, sizeof(prelude_code<%=i%>) - 1),
+ rb_str_new(prelude_name<%=i%>, sizeof(prelude_name<%=i%>) - 1),
+ INT2FIX(<%=1-setup_lines.length%>)));
-! }
+% }
#if 0
-! preludes.length.times {|i|
- puts(prelude_code<%i%>);
-! }
+% preludes.length.times {|i|
+ puts(prelude_code<%=i%>);
+% }
#endif
}
EOS