summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-12-07 13:56:25 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-12-07 13:59:00 +0900
commited29d74bfd95362eaeb946fcf7e865d80346b62b (patch)
tree48630cbbfa207910348d3f5e5d8c7d74545b31b2
parent8b52c67be9473571790dc10fbfd5fdbcdba5cef6 (diff)
downloadmruby-ed29d74bfd95362eaeb946fcf7e865d80346b62b.tar.gz
mruby-ed29d74bfd95362eaeb946fcf7e865d80346b62b.zip
Make type of `pc` arguments in `debug.c` consistent; close #5218
They used to be `size_t`, `uint32_t` and `ptrdiff_t`. Now all of them made to be `uint32_t`.
-rw-r--r--include/mruby/debug.h4
-rw-r--r--src/debug.c10
2 files changed, 7 insertions, 7 deletions
diff --git a/include/mruby/debug.h b/include/mruby/debug.h
index f22c7c77b..2062a9308 100644
--- a/include/mruby/debug.h
+++ b/include/mruby/debug.h
@@ -46,13 +46,13 @@ typedef struct mrb_irep_debug_info {
* get line from irep's debug info and program counter
* @return returns NULL if not found
*/
-MRB_API const char *mrb_debug_get_filename(mrb_state *mrb, const mrb_irep *irep, ptrdiff_t pc);
+MRB_API const char *mrb_debug_get_filename(mrb_state *mrb, const mrb_irep *irep, uint32_t pc);
/*
* get line from irep's debug info and program counter
* @return returns -1 if not found
*/
-MRB_API int32_t mrb_debug_get_line(mrb_state *mrb, const mrb_irep *irep, size_t pc);
+MRB_API int32_t mrb_debug_get_line(mrb_state *mrb, const mrb_irep *irep, uint32_t pc);
MRB_API mrb_irep_debug_info *mrb_debug_info_alloc(mrb_state *mrb, mrb_irep *irep);
MRB_API mrb_irep_debug_info_file *mrb_debug_info_append_file(
diff --git a/src/debug.c b/src/debug.c
index dabc5a56d..2f9320ac9 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -51,12 +51,12 @@ select_line_type(const uint16_t *lines, size_t lines_len)
}
MRB_API char const*
-mrb_debug_get_filename(mrb_state *mrb, const mrb_irep *irep, ptrdiff_t pc)
+mrb_debug_get_filename(mrb_state *mrb, const mrb_irep *irep, uint32_t pc)
{
- if (irep && pc >= 0 && pc < irep->ilen) {
+ if (irep && pc < irep->ilen) {
mrb_irep_debug_info_file* f = NULL;
if (!irep->debug_info) return NULL;
- else if ((f = get_file(irep->debug_info, (uint32_t)pc))) {
+ else if ((f = get_file(irep->debug_info, pc))) {
return mrb_sym_name_len(mrb, f->filename_sym, NULL);
}
}
@@ -64,14 +64,14 @@ mrb_debug_get_filename(mrb_state *mrb, const mrb_irep *irep, ptrdiff_t pc)
}
MRB_API int32_t
-mrb_debug_get_line(mrb_state *mrb, const mrb_irep *irep, size_t pc)
+mrb_debug_get_line(mrb_state *mrb, const mrb_irep *irep, uint32_t pc)
{
if (irep && pc >= 0 && pc < irep->ilen) {
mrb_irep_debug_info_file* f = NULL;
if (!irep->debug_info) {
return -1;
}
- else if ((f = get_file(irep->debug_info, (uint32_t)pc))) {
+ else if ((f = get_file(irep->debug_info, pc))) {
switch (f->line_type) {
case mrb_debug_line_ary:
mrb_assert(f->start_pos <= pc && pc < (f->start_pos + f->line_entry_count));