diff options
| author | take_cheeze <[email protected]> | 2013-09-01 22:43:17 +0900 |
|---|---|---|
| committer | take_cheeze <[email protected]> | 2013-09-02 00:48:06 +0900 |
| commit | 3d1fffbd6bce3a6f9a77af3116078574ce8d5fe9 (patch) | |
| tree | 35d6c58a23442ca055671c3b9e34f736153bc4ec /include | |
| parent | bc131350d416409220fd3294d2ffcea3ae73027d (diff) | |
| download | mruby-3d1fffbd6bce3a6f9a77af3116078574ce8d5fe9.tar.gz mruby-3d1fffbd6bce3a6f9a77af3116078574ce8d5fe9.zip | |
support multiple filename in irep
Diffstat (limited to 'include')
| -rw-r--r-- | include/mruby/compile.h | 5 | ||||
| -rw-r--r-- | include/mruby/debug.h | 57 | ||||
| -rwxr-xr-x | include/mruby/dump.h | 12 | ||||
| -rw-r--r-- | include/mruby/irep.h | 1 |
4 files changed, 72 insertions, 3 deletions
diff --git a/include/mruby/compile.h b/include/mruby/compile.h index 7c5884e58..387206686 100644 --- a/include/mruby/compile.h +++ b/include/mruby/compile.h @@ -38,6 +38,7 @@ void mrbc_partial_hook(mrb_state *mrb, mrbc_context *c, int (*partial_hook)(stru typedef struct mrb_ast_node { struct mrb_ast_node *car, *cdr; short lineno; + char const* filename; } mrb_ast_node; /* lexer states */ @@ -110,7 +111,7 @@ struct mrb_parser_state { FILE *f; #endif mrbc_context *cxt; - char *filename; + char const *filename; int lineno; int column; @@ -150,6 +151,8 @@ struct mrb_parser_state* mrb_parser_new(mrb_state*); void mrb_parser_free(struct mrb_parser_state*); void mrb_parser_parse(struct mrb_parser_state*,mrbc_context*); +void mrb_parser_set_filename(struct mrb_parser_state*, char const*); + /* utility functions */ #ifdef ENABLE_STDIO struct mrb_parser_state* mrb_parse_file(mrb_state*,FILE*,mrbc_context*); diff --git a/include/mruby/debug.h b/include/mruby/debug.h new file mode 100644 index 000000000..0f60c9c84 --- /dev/null +++ b/include/mruby/debug.h @@ -0,0 +1,57 @@ +#ifndef MRUBY_DEBUG_H +#define MRUBY_DEBUG_H + +#include <stdint.h> +#include "mruby/value.h" + +typedef enum mrb_debug_line_type { + mrb_debug_line_ary = 0, + mrb_debug_line_flat_map = 1 +} mrb_debug_line_type; + +typedef struct mrb_irep_debug_info_line { + uint32_t start_pos; + uint16_t line; +} mrb_irep_debug_info_line; + +typedef struct mrb_irep_debug_info_file { + uint32_t start_pos; + char const* filename; + mrb_sym filename_sym; + uint32_t line_entry_count; + mrb_debug_line_type line_type; + union { + void* line_ptr; + mrb_irep_debug_info_line* line_flat_map; + uint16_t* line_ary; + }; +} mrb_irep_debug_info_file; + +typedef struct mrb_irep_debug_info { + uint32_t pc_count; + uint16_t flen; + mrb_irep_debug_info_file** files; +} mrb_irep_debug_info; + +struct mrb_irep; +struct mrb_state; + +/* + * get line from irep's debug info and program counter + * @return returns NULL if not found + */ +char const* mrb_get_filename(struct mrb_irep* irep, uint32_t pc); + +/* + * get line from irep's debug info and program counter + * @return returns -1 if not found + */ +int32_t mrb_get_line(struct mrb_irep* irep, uint32_t pc); + +mrb_irep_debug_info_file* mrb_debug_info_append_file( + struct mrb_state* mrb, struct mrb_irep* irep, + uint32_t start_pos, uint32_t end_pos); +mrb_irep_debug_info* mrb_debug_info_alloc(struct mrb_state* mrb, struct mrb_irep* irep); +void mrb_debug_info_free(struct mrb_state* mrb, mrb_irep_debug_info* d); + +#endif /* MRUBY_DEBUG_H */ diff --git a/include/mruby/dump.h b/include/mruby/dump.h index 55227c8cf..e75be9f07 100755 --- a/include/mruby/dump.h +++ b/include/mruby/dump.h @@ -52,6 +52,7 @@ mrb_value mrb_load_irep_file(mrb_state*,FILE*); #define RITE_BINARY_EOF "END\0" #define RITE_SECTION_IREP_IDENTIFIER "IREP" #define RITE_SECTION_LINENO_IDENTIFIER "LINE" +#define RITE_SECTION_DEBUG_IDENTIFIER "DBG\0" #define MRB_DUMP_DEFAULT_STR_LEN 128 @@ -79,14 +80,21 @@ struct rite_section_irep_header { uint8_t rite_version[4]; // Rite Instruction Specification Version uint8_t nirep[2]; // Number of ireps - uint8_t sirep[2]; // Start index + uint8_t sirep[2]; // Start index }; struct rite_section_lineno_header { RITE_SECTION_HEADER; uint8_t nirep[2]; // Number of ireps - uint8_t sirep[2]; // Start index + uint8_t sirep[2]; // Start index +}; + +struct rite_section_debug_header { + RITE_SECTION_HEADER; + + uint8_t nirep[2]; // Number of ireps + uint8_t sirep[2]; // Start index }; struct rite_binary_footer { diff --git a/include/mruby/irep.h b/include/mruby/irep.h index 498b58ca3..56e043e74 100644 --- a/include/mruby/irep.h +++ b/include/mruby/irep.h @@ -25,6 +25,7 @@ typedef struct mrb_irep { /* debug info */ const char *filename; uint16_t *lines; + struct mrb_irep_debug_info* debug_info; size_t ilen, plen, slen; } mrb_irep; |
