Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1560,15 +1560,22 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *anchor)
}
case TS_CDHASH:
{
int i;
VALUE map = operands[j];
struct cdhash_set_label_struct data;
data.hash = map;
data.pos = pos;
data.len = len;
rb_hash_foreach(map, cdhash_set_label_i, (VALUE)&data);
data.hash = map;
data.pos = pos;
data.len = len;
if (RB_TYPE_P(map, T_ARRAY)) {
data.hash = rb_hash_new();
for (i=0; i<RARRAY_LEN(map); i+=2)
cdhash_set_label_i(RARRAY_AREF(map, i), RARRAY_AREF(map, i+1), &data);
} else {
rb_hash_foreach(map, cdhash_set_label_i, (VALUE)&data);
}

hide_obj(map);
generated_iseq[pos + 1 + j] = map;
hide_obj(data.hash);
generated_iseq[pos + 1 + j] = data.hash;
break;
}
case TS_LINDEX:
Expand Down
7 changes: 6 additions & 1 deletion iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,12 @@ iseq_data_to_ary(rb_iseq_t *iseq)
for (i=0; i<iseq->local_table_size; i++) {
ID lid = iseq->local_table[i];
if (lid) {
if (rb_id2str(lid)) rb_ary_push(locals, ID2SYM(lid));
if (rb_id2str(lid)) {
rb_ary_push(locals, ID2SYM(lid));
}
else { /* hidden variable from id_internal() */
rb_ary_push(locals, ULONG2NUM(iseq->local_table_size-i+1));
}
}
else {
rb_ary_push(locals, ID2SYM(rb_intern("#arg_rest")));
Expand Down
27 changes: 21 additions & 6 deletions load.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "eval_intern.h"
#include "probes.h"
#include "node.h"
#include "iseq.h"
#include "vm_debug.h"

VALUE ruby_dln_librefs;

Expand Down Expand Up @@ -606,12 +608,25 @@ rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
if (state == 0) {
NODE *node;
VALUE iseq;

th->mild_compile_error++;
node = (NODE *)rb_load_file_str(fname);
loaded = TRUE;
iseq = rb_iseq_new_top(node, rb_str_new2("<top (required)>"), fname, rb_realpath_internal(Qnil, fname, 1), Qfalse);
th->mild_compile_error--;
VALUE io;
VALUE fcname = rb_str_plus(fname, rb_str_new2("o"));

if (RTEST(rb_funcall(rb_cFile, rb_intern("exist?"), 1, fcname))) {
dpv("loading bytecode from", fcname);
iseq = rb_iseq_load(rb_marshal_load(rb_funcall(rb_cIO, rb_intern("binread"), 1, fcname)), Qnil, Qnil);
loaded = TRUE;
} else {
th->mild_compile_error++;
node = (NODE *)rb_load_file_str(fname);
loaded = TRUE;
iseq = rb_iseq_new_top(node, rb_str_new2("<top (required)>"), fname, rb_realpath_internal(Qnil, fname, 1), Qfalse);
th->mild_compile_error--;

io = rb_file_open_str(fcname, "w");
rb_marshal_dump(rb_funcall(iseq, rb_intern("to_a"), 0), io);
rb_io_close(io);
dpv("wrote bytecode to", fcname);
}
rb_iseq_eval(iseq);
}
POP_TAG();
Expand Down