Check loading built-in binaries
This commit is contained in:
parent
5889cbd7de
commit
677c3228d0
Notes:
git
2023-03-08 04:59:38 +00:00
@ -48,6 +48,7 @@ rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin
|
||||
vm->builtin_function_table = table;
|
||||
vm->builtin_inline_index = 0;
|
||||
const rb_iseq_t *iseq = rb_iseq_ibf_load_bytes((const char *)bin, size);
|
||||
ASSUME(iseq); // otherwise an exception should have raised
|
||||
vm->builtin_function_table = NULL;
|
||||
|
||||
// exec
|
||||
|
@ -21,6 +21,11 @@ builtin_iseq_load(const char *feature_name, const struct rb_builtin_function *ta
|
||||
rb_ast_t *ast = rb_builtin_ast(feature_name, &name_str);
|
||||
rb_vm_t *vm = GET_VM();
|
||||
|
||||
if (!ast) {
|
||||
rb_fatal("builtin_iseq_load: can not find %s; "
|
||||
"probably miniprelude.c is out of date",
|
||||
feature_name);
|
||||
}
|
||||
vm->builtin_function_table = table;
|
||||
vm->builtin_inline_index = 0;
|
||||
static const rb_compile_option_t optimization = {
|
||||
|
@ -10,19 +10,19 @@ static const unsigned char <%= feature %>_bin[] = {
|
||||
% iseq \
|
||||
% . to_binary \
|
||||
% . each_byte \
|
||||
% . map(&:ord) \
|
||||
% . map{ '0x%02x' % _1 } \
|
||||
% . each_slice(12) {|a|
|
||||
<%= a.join(', ') %>,
|
||||
<%= a.map{ '0x%02x,' % _1 }.join(' ') %>
|
||||
% }
|
||||
};
|
||||
% }
|
||||
|
||||
#define BUILTIN_BIN(feature) \
|
||||
{ #feature, feature ## _bin, sizeof(feature ## _bin), }
|
||||
static const struct builtin_binary builtin_binary[] = {
|
||||
% ary.each{|feature, |
|
||||
{ <%= feature.dump %>, <%= feature %>_bin, sizeof(<%= feature %>_bin), },
|
||||
BUILTIN_BIN(<%= feature %>),
|
||||
% }
|
||||
{ NULL, },<%# dummy entry %>
|
||||
{ NULL, },/* sentinel */
|
||||
};
|
||||
|
||||
#define BUILTIN_BINARY_SIZE <%= ary.size %>
|
||||
|
@ -140,8 +140,8 @@ static rb_ast_t *
|
||||
prelude_ast(VALUE name, VALUE code, int line)
|
||||
{
|
||||
rb_ast_t *ast = rb_parser_compile_string_path(rb_parser_new(), name, code, line);
|
||||
if (!ast->body.root) {
|
||||
rb_ast_dispose(ast);
|
||||
if (!ast || !ast->body.root) {
|
||||
if (ast) rb_ast_dispose(ast);
|
||||
rb_exc_raise(rb_errinfo());
|
||||
}
|
||||
return ast;
|
||||
@ -208,7 +208,7 @@ Init_<%=init_name%><%=%>(void)
|
||||
%unless @prelude_count.zero?
|
||||
% preludes.each do |i, prelude, lines, sub, start_line|
|
||||
% next if sub
|
||||
prelude_eval(PRELUDE_CODE(<%=i%><%=%>), PRELUDE_NAME(<%=i%><%=%>), <%=start_line%>);
|
||||
prelude_eval(PRELUDE_CODE(<%=i%><%=%>), PRELUDE_NAME(<%=i%><%=%>), <%=start_line%><%=%>);
|
||||
% end
|
||||
|
||||
#if 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user