mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Rework first_lineno
to be int
.
This commit is contained in:
parent
a95b741a97
commit
75cf29f60d
Notes:
git
2022-09-25 20:41:49 +09:00
5 changed files with 24 additions and 25 deletions
|
@ -1333,7 +1333,7 @@ new_child_iseq(rb_iseq_t *iseq, const NODE *const node,
|
|||
int isolated_depth = ISEQ_COMPILE_DATA(iseq)->isolated_depth;
|
||||
ret_iseq = rb_iseq_new_with_opt(&ast, name,
|
||||
rb_iseq_path(iseq), rb_iseq_realpath(iseq),
|
||||
INT2FIX(line_no), parent,
|
||||
line_no, parent,
|
||||
isolated_depth ? isolated_depth + 1 : 0,
|
||||
type, ISEQ_COMPILE_DATA(iseq)->option);
|
||||
debugs("[new_child_iseq]< ---------------------------------------\n");
|
||||
|
@ -1349,7 +1349,7 @@ new_child_iseq_with_callback(rb_iseq_t *iseq, const struct rb_iseq_new_with_call
|
|||
debugs("[new_child_iseq_with_callback]> ---------------------------------------\n");
|
||||
ret_iseq = rb_iseq_new_with_callback(ifunc, name,
|
||||
rb_iseq_path(iseq), rb_iseq_realpath(iseq),
|
||||
INT2FIX(line_no), parent, type, ISEQ_COMPILE_DATA(iseq)->option);
|
||||
line_no, parent, type, ISEQ_COMPILE_DATA(iseq)->option);
|
||||
debugs("[new_child_iseq_with_callback]< ---------------------------------------\n");
|
||||
return ret_iseq;
|
||||
}
|
||||
|
@ -8231,7 +8231,7 @@ compile_builtin_mandatory_only_method(rb_iseq_t *iseq, const NODE *node, const N
|
|||
ISEQ_BODY(iseq)->mandatory_only_iseq =
|
||||
rb_iseq_new_with_opt(&ast, rb_iseq_base_label(iseq),
|
||||
rb_iseq_path(iseq), rb_iseq_realpath(iseq),
|
||||
INT2FIX(nd_line(line_node)), NULL, 0,
|
||||
nd_line(line_node), NULL, 0,
|
||||
ISEQ_TYPE_METHOD, ISEQ_COMPILE_DATA(iseq)->option);
|
||||
|
||||
GET_VM()->builtin_inline_index = prev_inline_index;
|
||||
|
|
31
iseq.c
31
iseq.c
|
@ -591,14 +591,14 @@ rb_iseq_pathobj_set(const rb_iseq_t *iseq, VALUE path, VALUE realpath)
|
|||
}
|
||||
|
||||
static rb_iseq_location_t *
|
||||
iseq_location_setup(rb_iseq_t *iseq, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_code_location_t *code_location, const int node_id)
|
||||
iseq_location_setup(rb_iseq_t *iseq, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_code_location_t *code_location, const int node_id)
|
||||
{
|
||||
rb_iseq_location_t *loc = &ISEQ_BODY(iseq)->location;
|
||||
|
||||
rb_iseq_pathobj_set(iseq, path, realpath);
|
||||
RB_OBJ_WRITE(iseq, &loc->label, name);
|
||||
RB_OBJ_WRITE(iseq, &loc->base_label, name);
|
||||
loc->first_lineno = first_lineno;
|
||||
loc->first_lineno = RB_INT2NUM(first_lineno);
|
||||
if (code_location) {
|
||||
loc->node_id = node_id;
|
||||
loc->code_location = *code_location;
|
||||
|
@ -656,7 +656,7 @@ new_arena(void)
|
|||
|
||||
static VALUE
|
||||
prepare_iseq_build(rb_iseq_t *iseq,
|
||||
VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_code_location_t *code_location, const int node_id,
|
||||
VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_code_location_t *code_location, const int node_id,
|
||||
const rb_iseq_t *parent, int isolated_depth, enum rb_iseq_type type,
|
||||
VALUE script_lines, const rb_compile_option_t *option)
|
||||
{
|
||||
|
@ -882,7 +882,7 @@ rb_iseq_t *
|
|||
rb_iseq_new(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath,
|
||||
const rb_iseq_t *parent, enum rb_iseq_type type)
|
||||
{
|
||||
return rb_iseq_new_with_opt(ast, name, path, realpath, INT2FIX(0), parent,
|
||||
return rb_iseq_new_with_opt(ast, name, path, realpath, 0, parent,
|
||||
0, type, &COMPILE_OPTION_DEFAULT);
|
||||
}
|
||||
|
||||
|
@ -924,7 +924,7 @@ rb_iseq_new_top(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath
|
|||
iseq_setup_coverage(coverages, path, ast, 0);
|
||||
}
|
||||
|
||||
return rb_iseq_new_with_opt(ast, name, path, realpath, INT2FIX(0), parent, 0,
|
||||
return rb_iseq_new_with_opt(ast, name, path, realpath, 0, parent, 0,
|
||||
ISEQ_TYPE_TOP, &COMPILE_OPTION_DEFAULT);
|
||||
}
|
||||
|
||||
|
@ -932,17 +932,16 @@ rb_iseq_t *
|
|||
rb_iseq_new_main(const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt)
|
||||
{
|
||||
return rb_iseq_new_with_opt(ast, rb_fstring_lit("<main>"),
|
||||
path, realpath, INT2FIX(0),
|
||||
path, realpath, 0,
|
||||
parent, 0, ISEQ_TYPE_MAIN, opt ? &COMPILE_OPTION_DEFAULT : &COMPILE_OPTION_FALSE);
|
||||
}
|
||||
|
||||
rb_iseq_t *
|
||||
rb_iseq_new_eval(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_iseq_t *parent, int isolated_depth)
|
||||
rb_iseq_new_eval(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth)
|
||||
{
|
||||
VALUE coverages = rb_get_coverages();
|
||||
if (RTEST(coverages) && RTEST(path) && !RTEST(rb_hash_has_key(coverages, path))) {
|
||||
int line_offset = RB_NUM2INT(first_lineno) - 1;
|
||||
iseq_setup_coverage(coverages, path, ast, line_offset);
|
||||
iseq_setup_coverage(coverages, path, ast, first_lineno - 1);
|
||||
}
|
||||
|
||||
return rb_iseq_new_with_opt(ast, name, path, realpath, first_lineno,
|
||||
|
@ -965,7 +964,7 @@ iseq_translate(rb_iseq_t *iseq)
|
|||
|
||||
rb_iseq_t *
|
||||
rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath,
|
||||
VALUE first_lineno, const rb_iseq_t *parent, int isolated_depth,
|
||||
int first_lineno, const rb_iseq_t *parent, int isolated_depth,
|
||||
enum rb_iseq_type type, const rb_compile_option_t *option)
|
||||
{
|
||||
const NODE *node = ast ? ast->root : 0;
|
||||
|
@ -1003,7 +1002,7 @@ rb_iseq_t *
|
|||
rb_iseq_new_with_callback(
|
||||
const struct rb_iseq_new_with_callback_callback_func * ifunc,
|
||||
VALUE name, VALUE path, VALUE realpath,
|
||||
VALUE first_lineno, const rb_iseq_t *parent,
|
||||
int first_lineno, const rb_iseq_t *parent,
|
||||
enum rb_iseq_type type, const rb_compile_option_t *option)
|
||||
{
|
||||
/* TODO: argument check */
|
||||
|
@ -1069,7 +1068,7 @@ iseq_load(VALUE data, const rb_iseq_t *parent, VALUE opt)
|
|||
rb_iseq_t *iseq = iseq_alloc();
|
||||
|
||||
VALUE magic, version1, version2, format_type, misc;
|
||||
VALUE name, path, realpath, first_lineno, code_location, node_id;
|
||||
VALUE name, path, realpath, code_location, node_id;
|
||||
VALUE type, body, locals, params, exception;
|
||||
|
||||
st_data_t iseq_type;
|
||||
|
@ -1095,7 +1094,7 @@ iseq_load(VALUE data, const rb_iseq_t *parent, VALUE opt)
|
|||
path = CHECK_STRING(rb_ary_entry(data, i++));
|
||||
realpath = rb_ary_entry(data, i++);
|
||||
realpath = NIL_P(realpath) ? Qnil : CHECK_STRING(realpath);
|
||||
first_lineno = CHECK_INTEGER(rb_ary_entry(data, i++));
|
||||
int first_lineno = RB_NUM2INT(rb_ary_entry(data, i++));
|
||||
|
||||
type = CHECK_SYMBOL(rb_ary_entry(data, i++));
|
||||
locals = CHECK_ARRAY(rb_ary_entry(data, i++));
|
||||
|
@ -1189,7 +1188,7 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, V
|
|||
rb_exc_raise(GET_EC()->errinfo);
|
||||
}
|
||||
else {
|
||||
iseq = rb_iseq_new_with_opt(&ast->body, name, file, realpath, line,
|
||||
iseq = rb_iseq_new_with_opt(&ast->body, name, file, realpath, ln,
|
||||
NULL, 0, ISEQ_TYPE_TOP, &option);
|
||||
rb_ast_dispose(ast);
|
||||
}
|
||||
|
@ -1428,7 +1427,7 @@ iseqw_s_compile(int argc, VALUE *argv, VALUE self)
|
|||
static VALUE
|
||||
iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE file, line = INT2FIX(1), opt = Qnil;
|
||||
VALUE file, opt = Qnil;
|
||||
VALUE parser, f, exc = Qnil, ret;
|
||||
rb_ast_t *ast;
|
||||
rb_compile_option_t option;
|
||||
|
@ -1460,7 +1459,7 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
|
|||
ret = iseqw_new(rb_iseq_new_with_opt(&ast->body, rb_fstring_lit("<main>"),
|
||||
file,
|
||||
rb_realpath_internal(Qnil, file, 1),
|
||||
line, NULL, 0, ISEQ_TYPE_TOP, &option));
|
||||
1, NULL, 0, ISEQ_TYPE_TOP, &option));
|
||||
rb_ast_dispose(ast);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ builtin_iseq_load(const char *feature_name, const struct rb_builtin_function *ta
|
|||
FALSE, /* unsigned int coverage_enabled; */
|
||||
0, /* int debug_level; */
|
||||
};
|
||||
const rb_iseq_t *iseq = rb_iseq_new_with_opt(&ast->body, name_str, name_str, Qnil, INT2FIX(0), NULL, 0, ISEQ_TYPE_TOP, &optimization);
|
||||
const rb_iseq_t *iseq = rb_iseq_new_with_opt(&ast->body, name_str, name_str, Qnil, 0, NULL, 0, ISEQ_TYPE_TOP, &optimization);
|
||||
GET_VM()->builtin_function_table = NULL;
|
||||
|
||||
rb_ast_dispose(ast);
|
||||
|
|
|
@ -310,7 +310,7 @@ typedef struct rb_iseq_location_struct {
|
|||
VALUE pathobj; /* String (path) or Array [path, realpath]. Frozen. */
|
||||
VALUE base_label; /* String */
|
||||
VALUE label; /* String */
|
||||
VALUE first_lineno; /* TODO: may be unsigned short */
|
||||
VALUE first_lineno;
|
||||
int node_id;
|
||||
rb_code_location_t code_location;
|
||||
} rb_iseq_location_t;
|
||||
|
@ -1128,8 +1128,8 @@ RUBY_SYMBOL_EXPORT_BEGIN
|
|||
rb_iseq_t *rb_iseq_new (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, enum rb_iseq_type);
|
||||
rb_iseq_t *rb_iseq_new_top (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent);
|
||||
rb_iseq_t *rb_iseq_new_main (const rb_ast_body_t *ast, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt);
|
||||
rb_iseq_t *rb_iseq_new_eval (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_iseq_t *parent, int isolated_depth);
|
||||
rb_iseq_t *rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_iseq_t *parent, int isolated_depth,
|
||||
rb_iseq_t *rb_iseq_new_eval (const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth);
|
||||
rb_iseq_t *rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpath, int first_lineno, const rb_iseq_t *parent, int isolated_depth,
|
||||
enum rb_iseq_type, const rb_compile_option_t*);
|
||||
|
||||
struct iseq_link_anchor;
|
||||
|
@ -1147,7 +1147,7 @@ rb_iseq_new_with_callback_new_callback(
|
|||
return (struct rb_iseq_new_with_callback_callback_func *)memo;
|
||||
}
|
||||
rb_iseq_t *rb_iseq_new_with_callback(const struct rb_iseq_new_with_callback_callback_func * ifunc,
|
||||
VALUE name, VALUE path, VALUE realpath, VALUE first_lineno,
|
||||
VALUE name, VALUE path, VALUE realpath, int first_lineno,
|
||||
const rb_iseq_t *parent, enum rb_iseq_type, const rb_compile_option_t*);
|
||||
|
||||
VALUE rb_iseq_disasm(const rb_iseq_t *iseq);
|
||||
|
|
|
@ -1718,7 +1718,7 @@ eval_make_iseq(VALUE src, VALUE fname, int line, const rb_binding_t *bind,
|
|||
|
||||
iseq = rb_iseq_new_eval(&ast->body,
|
||||
ISEQ_BODY(parent)->location.label,
|
||||
fname, Qnil, INT2FIX(line),
|
||||
fname, Qnil, line,
|
||||
parent, isolated_depth);
|
||||
}
|
||||
rb_ast_dispose(ast);
|
||||
|
|
Loading…
Reference in a new issue