diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2017-06-18 14:00:02 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2017-06-18 14:17:41 +0300 |
commit | ffb02f79f0381f296e73add258f87ecb2456fba3 (patch) | |
tree | 5d074c615fb42e58ae03145c4ad4a35da63dd9db /src | |
parent | 565ff017ae9e52bbe41ccfb90668a642a2704afe (diff) | |
download | mailfromd-ffb02f79f0381f296e73add258f87ecb2456fba3.tar.gz mailfromd-ffb02f79f0381f296e73add258f87ecb2456fba3.tar.bz2 |
Switch to detailed source locations from Mailutils 3.2.92
* configure.ac: Version 8.1.92
* NEWS: Update.
* src/builtin/debug.bi (debug): Use mu_locus_range
* src/builtin/from.bi: Likewise.
* src/builtin/header.bi: Likewise.
* src/builtin/progress.bi: Likewise.
* src/builtin/qrnt.bi: Likewise.
* src/builtin/rcpt.bi: Likewise.
* src/exclist.c: Likewise.
* src/builtin/sieve.bi: Use mu_locus_range
(sieve): Accept new optional argument "col".
* src/drivers.c: Use mu_locus_range
(MARK_LOCUS): Rewrite as inline function.
* src/gram.y: Use mu_locus_range and location macros from mailutils/yyloc.h
Improve error diagnostics
(parse_program): Prepare mu_strerr for locus-aware diagnostics.
* src/lex.l: Use mu_linetrack_t to track locations.
* src/mailfromd.h: Use mu_locus_range
* src/main.c: Likewise.
* src/pp.c: Likewise.
* src/prog.c: Likewise.
* src/prog.h: Likewise.
* src/symbols.c: Likewise.
* tests/ashadow.at: Expect detailed error locations.
* tests/bctx00.at: Likewise.
* tests/fctx00.at: Likewise.
* tests/invcidr.at: Likewise.
* tests/invcidr2.at: Likewise.
* tests/module04.at: Likewise.
* tests/module06.at: Likewise.
* tests/poll04.at: Likewise.
* tests/setvar.at: Likewise.
* tests/shadow.at: Likewise.
* tests/static02.at: Likewise.
Diffstat (limited to 'src')
-rw-r--r-- | src/builtin/debug.bi | 10 | ||||
-rw-r--r-- | src/builtin/from.bi | 6 | ||||
-rw-r--r-- | src/builtin/header.bi | 40 | ||||
-rw-r--r-- | src/builtin/progress.bi | 6 | ||||
-rw-r--r-- | src/builtin/qrnt.bi | 6 | ||||
-rw-r--r-- | src/builtin/rcpt.bi | 12 | ||||
-rw-r--r-- | src/builtin/sieve.bi | 21 | ||||
-rw-r--r-- | src/drivers.c | 178 | ||||
-rw-r--r-- | src/exclist.c | 2 | ||||
-rw-r--r-- | src/gram.y | 540 | ||||
-rw-r--r-- | src/lex.l | 195 | ||||
-rw-r--r-- | src/mailfromd.h | 61 | ||||
-rw-r--r-- | src/main.c | 28 | ||||
-rw-r--r-- | src/pp.c | 69 | ||||
-rw-r--r-- | src/prog.c | 55 | ||||
-rw-r--r-- | src/prog.h | 16 | ||||
-rw-r--r-- | src/symbols.c | 33 |
17 files changed, 650 insertions, 628 deletions
diff --git a/src/builtin/debug.bi b/src/builtin/debug.bi index 9645b7c1..65c17486 100644 --- a/src/builtin/debug.bi +++ b/src/builtin/debug.bi @@ -66,18 +66,14 @@ END MF_DEFUN(debug, VOID, STRING spec) { - struct locus loc; - struct mu_locus mloc; + struct mu_locus_range loc = MU_LOCUS_RANGE_INITIALIZER; env_get_locus(env, &loc); - mloc.mu_file = (char*)loc.file; - mloc.mu_line = loc.line; - mloc.mu_col = loc.point; mu_stream_ioctl(mu_strerr, MU_IOCTL_LOGSTREAM, - MU_IOCTL_LOGSTREAM_SET_LOCUS, &mloc); + MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE, &loc); mu_debug_parse_spec(spec); mu_stream_ioctl(mu_strerr, MU_IOCTL_LOGSTREAM, - MU_IOCTL_LOGSTREAM_SET_LOCUS, NULL); + MU_IOCTL_LOGSTREAM_SET_LOCUS_RANGE, NULL); } END diff --git a/src/builtin/from.bi b/src/builtin/from.bi index 7bcd2421..ea2e16b9 100644 --- a/src/builtin/from.bi +++ b/src/builtin/from.bi @@ -16,13 +16,13 @@ MF_DEFUN(set_from, VOID, STRING addr, OPTIONAL, STRING args) { - struct locus locus; + struct mu_locus_range locus; env_get_locus(env, &locus); - trace("%s%s:%lu: %s %s", + trace("%s%s:%u: %s %s", mailfromd_msgid(env_get_context(env)), - locus.file, locus.line, + locus.beg.mu_file, locus.beg.mu_line, msgmod_opcode_str(set_from), addr); env_msgmod(env, set_from, addr, MF_OPTVAL(args, NULL), 0); diff --git a/src/builtin/header.bi b/src/builtin/header.bi index 64ded907..162130be 100644 --- a/src/builtin/header.bi +++ b/src/builtin/header.bi @@ -16,22 +16,22 @@ MF_DEFUN(header_add, VOID, STRING name, STRING value, OPTIONAL, NUMBER idx) { - struct locus locus; + struct mu_locus_range locus; env_get_locus(env, &locus); if (MF_DEFINED(idx)) { - trace("%s%s:%lu: %s %ld \"%s: %s\"", + trace("%s%s:%u: %s %ld \"%s: %s\"", mailfromd_msgid(env_get_context(env)), - locus.file, locus.line, + locus.beg.mu_file, locus.beg.mu_line, msgmod_opcode_str(header_insert), idx, name, value); env_msgmod(env, header_insert, name, value, idx); } else { - trace("%s%s:%lu: %s \"%s: %s\"", + trace("%s%s:%u: %s \"%s: %s\"", mailfromd_msgid(env_get_context(env)), - locus.file, locus.line, + locus.beg.mu_file, locus.beg.mu_line, msgmod_opcode_str(header_add), name, value); env_msgmod(env, header_add, name, value, 1); @@ -41,13 +41,13 @@ END MF_DEFUN(header_insert, VOID, STRING name, STRING value, NUMBER idx) { - struct locus locus; + struct mu_locus_range locus; env_get_locus(env, &locus); - trace("%s%s:%lu: %s %ld \"%s: %s\"", + trace("%s%s:%u: %s %ld \"%s: %s\"", mailfromd_msgid(env_get_context(env)), - locus.file, locus.line, + locus.beg.mu_file, locus.beg.mu_line, msgmod_opcode_str(header_insert), idx, name, value); @@ -57,13 +57,13 @@ END MF_DEFUN(header_delete, VOID, STRING name, OPTIONAL, NUMBER idx) { - struct locus locus; + struct mu_locus_range locus; env_get_locus(env, &locus); - trace("%s%s:%lu: %s \"%s\" (%lu)", + trace("%s%s:%u: %s \"%s\" (%lu)", mailfromd_msgid(env_get_context(env)), - locus.file, locus.line, + locus.beg.mu_file, locus.beg.mu_line, msgmod_opcode_str(header_delete), name, MF_OPTVAL(idx, 1)); env_msgmod(env, header_delete, name, NULL, MF_OPTVAL(idx, 1)); @@ -73,13 +73,13 @@ END MF_CAPTURE MF_DEFUN(header_delete_nth, VOID, NUMBER idx) { - struct locus locus; + struct mu_locus_range locus; env_get_locus(env, &locus); - trace("%s%s:%lu: %s %lu", + trace("%s%s:%u: %s %lu", mailfromd_msgid(env_get_context(env)), - locus.file, locus.line, + locus.beg.mu_file, locus.beg.mu_line, msgmod_opcode_str(header_delete_nth), idx); env_msgmod(env, header_delete_nth, NULL, NULL, idx); @@ -88,13 +88,13 @@ END MF_DEFUN(header_replace, VOID, STRING name, STRING value, OPTIONAL, NUMBER idx) { - struct locus locus; + struct mu_locus_range locus; env_get_locus(env, &locus); - trace("%s%s:%lu: %s \"%s: %s\" (%lu)", + trace("%s%s:%u: %s \"%s: %s\" (%lu)", mailfromd_msgid(env_get_context(env)), - locus.file, locus.line, + locus.beg.mu_file, locus.beg.mu_line, msgmod_opcode_str(header_replace), name, value, MF_OPTVAL(idx, 1)); env_msgmod(env, header_replace, name, value, MF_OPTVAL(idx, 1)); @@ -104,13 +104,13 @@ END MF_CAPTURE MF_DEFUN(header_replace_nth, VOID, NUMBER idx, STRING name, STRING value) { - struct locus locus; + struct mu_locus_range locus; env_get_locus(env, &locus); - trace("%s%s:%lu: %s \"%s: %s\" (%lu)", + trace("%s%s:%u: %s \"%s: %s\" (%lu)", mailfromd_msgid(env_get_context(env)), - locus.file, locus.line, + locus.beg.mu_file, locus.beg.mu_line, msgmod_opcode_str(header_replace_nth), name, value, idx); env_msgmod(env, header_replace_nth, name, value, idx); diff --git a/src/builtin/progress.bi b/src/builtin/progress.bi index 962c501b..b9a439cf 100644 --- a/src/builtin/progress.bi +++ b/src/builtin/progress.bi @@ -17,13 +17,13 @@ MF_STATE(eom) MF_DEFUN(progress, VOID) { - struct locus locus; + struct mu_locus_range locus; env_get_locus(env, &locus); - trace("%s%s:%lu: %s", + trace("%s%s:%u: %s", mailfromd_msgid(env_get_context(env)), - locus.file, locus.line, + locus.beg.mu_file, locus.beg.mu_line, "PROGRESS"); gacopyz_progress(env_get_context(env)); } diff --git a/src/builtin/qrnt.bi b/src/builtin/qrnt.bi index 5432deb8..91ca7dbf 100644 --- a/src/builtin/qrnt.bi +++ b/src/builtin/qrnt.bi @@ -16,13 +16,13 @@ MF_DEFUN(quarantine, VOID, STRING reason) { - struct locus locus; + struct mu_locus_range locus; env_get_locus(env, &locus); - trace("%s%s:%lu: %s %s", + trace("%s%s:%u: %s %s", mailfromd_msgid(env_get_context(env)), - locus.file, locus.line, + locus.beg.mu_file, locus.beg.mu_line, msgmod_opcode_str(quarantine), reason); env_msgmod(env, quarantine, reason, NULL, 0); diff --git a/src/builtin/rcpt.bi b/src/builtin/rcpt.bi index cf03c073..55563572 100644 --- a/src/builtin/rcpt.bi +++ b/src/builtin/rcpt.bi @@ -16,13 +16,13 @@ MF_DEFUN(rcpt_add, VOID, STRING addr) { - struct locus locus; + struct mu_locus_range locus; env_get_locus(env, &locus); - trace("%s%s:%lu: %s %s", + trace("%s%s:%u: %s %s", mailfromd_msgid(env_get_context(env)), - locus.file, locus.line, + locus.beg.mu_file, locus.beg.mu_line, msgmod_opcode_str(rcpt_add), addr); env_msgmod(env, rcpt_add, addr, NULL, 0); @@ -31,13 +31,13 @@ END MF_DEFUN(rcpt_delete, VOID, STRING addr) { - struct locus locus; + struct mu_locus_range locus; env_get_locus(env, &locus); - trace("%s%s:%lu: %s %s", + trace("%s%s:%u: %s %s", mailfromd_msgid(env_get_context(env)), - locus.file, locus.line, + locus.beg.mu_file, locus.beg.mu_line, msgmod_opcode_str(rcpt_delete), addr); env_msgmod(env, rcpt_delete, addr, NULL, 0); diff --git a/src/builtin/sieve.bi b/src/builtin/sieve.bi index 7af7721d..1a9cf9fe 100644 --- a/src/builtin/sieve.bi +++ b/src/builtin/sieve.bi @@ -46,15 +46,16 @@ _sieve_file_action_log(mu_sieve_machine_t mach, { mu_stream_t stream; eval_environ_t env = mu_sieve_get_data(mach); - struct locus locus; + struct mu_locus_range locus; _sieve_text_action_log(mach, action, fmt, ap); mu_sieve_get_diag_stream(mach, &stream); env_get_locus(env, &locus); - mu_stream_printf(stream, "\033f<%lu>%s\033l<%lu>\033s<%d>\033O<%d>%s\n", - (unsigned long) strlen(locus.file), locus.file, - locus.line, + mu_stream_printf(stream, "\033f<%lu>%s\033l<%u>\033s<%d>\033O<%d>%s\n", + (unsigned long) strlen(locus.beg.mu_file), + locus.beg.mu_file, + locus.beg.mu_line, MU_LOG_NOTICE, MU_LOGMODE_LOCUS|MU_LOGMODE_SEVERITY, _("sieve called from here")); @@ -77,7 +78,7 @@ modify_debug_flags(mu_debug_level_t set, mu_debug_level_t clr) } MF_DEFUN(sieve, NUMBER, NUMBER nmsg, STRING script, OPTIONAL, NUMBER flags, - STRING file, NUMBER line) + STRING file, NUMBER line, NUMBER col) { mu_sieve_machine_t mach; int rc; @@ -110,14 +111,16 @@ MF_DEFUN(sieve, NUMBER, NUMBER nmsg, STRING script, OPTIONAL, NUMBER flags, mu_sieve_set_data(mach, env); if (f & MF_SIEVE_TEXT) { - struct locus locus; + struct mu_locus_range locus = MU_LOCUS_RANGE_INITIALIZER; + struct mu_locus_point pt; env_get_locus(env, &locus); if (f & MF_SIEVE_LOG) mu_sieve_set_logger(mach, _sieve_text_action_log); - rc = mu_sieve_compile_buffer(mach, script, strlen(script), - MF_OPTVAL(file, locus.file), - MF_OPTVAL(line, locus.line)); + pt.mu_file = MF_OPTVAL(file, locus.beg.mu_file); + pt.mu_line = MF_OPTVAL(line, locus.beg.mu_line); + pt.mu_col = MF_OPTVAL(col, locus.beg.mu_col); + rc = mu_sieve_compile_text(mach, script, strlen(script), &pt); } else { if (f & MF_SIEVE_LOG) mu_sieve_set_logger(mach, _sieve_file_action_log); diff --git a/src/drivers.c b/src/drivers.c index 3b98ccc9..cbca6a5b 100644 --- a/src/drivers.c +++ b/src/drivers.c @@ -14,14 +14,18 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define MARK_LOCUS() \ - do if (!*old_locus || !LOCUS_EQ(*old_locus, &node->locus)) { \ - struct literal *lit = literal_lookup(node->locus.file); \ - *old_locus = &node->locus; \ - code_op(opcode_locus); \ - code_immediate(lit->off, ulong); \ - code_immediate(node->locus.line, str); \ - } while (0) +static inline void +mark_locus(NODE *node, struct mu_locus_range const **old_locus) +{ + if (!*old_locus + || !mu_locus_point_same_line (&(*old_locus)->beg, &node->locus.beg)) { + struct literal *lit = literal_lookup(node->locus.beg.mu_file); + *old_locus = &node->locus; + code_op(opcode_locus); + code_immediate(lit->off, ulong); + code_immediate(node->locus.beg.mu_line, ulong); + } +} static void code_trycatch_exit(unsigned id); static unsigned trycatch_last_id(void); @@ -74,9 +78,9 @@ mark_type_string(NODE *node) } void -code_type_string(NODE *node, struct locus **old_locus) +code_type_string(NODE *node, struct mu_locus_range const **old_locus) { - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_push); code_immediate(node->v.literal->off, size); } @@ -92,9 +96,9 @@ print_type_symbol(NODE *node, int level) } void -code_type_symbol(NODE *node, struct locus **old_locus) +code_type_symbol(NODE *node, struct mu_locus_range const **old_locus) { - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_symbol); code_immediate(node->v.literal->off, size); } @@ -115,9 +119,9 @@ print_type_number(NODE *node, int level) } void -code_type_number(NODE *node, struct locus **old_locus) +code_type_number(NODE *node, struct mu_locus_range const **old_locus) { - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_push); code_immediate(node->v.number, long); } @@ -198,12 +202,12 @@ optimize_type_if(NODE *node) } void -code_type_if(NODE *node, struct locus **old_locus) +code_type_if(NODE *node, struct mu_locus_range const **old_locus) { prog_counter_t pos1, pos2, endpos; code_node(node->v.cond.cond); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_bz); pos1 = code_immediate(NULL, ptr); traverse_tree(node->v.cond.if_true); @@ -767,7 +771,7 @@ optimize_type_bin(NODE *node) } while (0) void -code_type_bin(NODE *node, struct locus **old_locus) +code_type_bin(NODE *node, struct mu_locus_range const **old_locus) { prog_counter_t pos1, pos2; @@ -775,7 +779,7 @@ code_type_bin(NODE *node, struct locus **old_locus) switch (node->v.bin.opcode) { case bin_and: - MARK_LOCUS(); + mark_locus(node, old_locus); /* cond1 if not true goto X cond2 @@ -799,7 +803,7 @@ code_type_bin(NODE *node, struct locus **old_locus) break; case bin_or: - MARK_LOCUS(); + mark_locus(node, old_locus); /* cond1 if true goto X cond2 @@ -855,7 +859,7 @@ code_type_bin(NODE *node, struct locus **old_locus) case bin_match: code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); if (node->v.bin.qualifier & QUALIFIER_MX) code_op(opcode_regmatch_mx); else @@ -864,7 +868,7 @@ code_type_bin(NODE *node, struct locus **old_locus) case bin_fnmatch: code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); if (node->v.bin.qualifier & QUALIFIER_MX) code_op(opcode_fnmatch_mx); else @@ -873,61 +877,61 @@ code_type_bin(NODE *node, struct locus **old_locus) case bin_add: code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_add); break; case bin_sub: code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_sub); break; case bin_mul: code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_mul); break; case bin_div: code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_div); break; case bin_mod: code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_mod); break; case bin_logand: code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_logand); break; case bin_logor: code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_logor); break; case bin_logxor: code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_logxor); break; case bin_shl: code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_shl); break; case bin_shr: code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_shr); break; @@ -987,10 +991,10 @@ optimize_type_un(NODE *node) } void -code_type_un(NODE *node, struct locus **old_locus) +code_type_un(NODE *node, struct mu_locus_range const **old_locus) { code_node(node->v.un.arg); - MARK_LOCUS(); + mark_locus(node, old_locus); switch (node->v.un.opcode) { case unary_not: code_op(opcode_not); @@ -1076,7 +1080,7 @@ result_argptr(NODE *arg) } void -code_type_result(NODE *node, struct locus **old_locus) +code_type_result(NODE *node, struct mu_locus_range const **old_locus) { NODE *code, *xcode; @@ -1113,7 +1117,7 @@ code_type_result(NODE *node, struct locus **old_locus) code_result_arg(xcode); code_result_arg(code); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_result); code_immediate(node->v.ret.stat, int); code_op(opcode_nil); @@ -1145,9 +1149,9 @@ optimize_type_header(NODE *node) } void -code_type_header(NODE *node, struct locus **old_locus) +code_type_header(NODE *node, struct mu_locus_range const **old_locus) { - MARK_LOCUS(); + mark_locus(node, old_locus); if (node->v.hdr.value) code_node(node->v.hdr.value); else { @@ -1211,7 +1215,7 @@ optimize_type_builtin(NODE *node) } void -code_type_builtin(NODE *node, struct locus **old_locus) +code_type_builtin(NODE *node, struct mu_locus_range const **old_locus) { NODE *p; int i; @@ -1227,7 +1231,7 @@ code_type_builtin(NODE *node, struct locus **old_locus) code_immediate(i, size); } - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_builtin); s = literal_lookup(node->v.builtin.builtin->name); code_immediate(s->off, size); @@ -1285,7 +1289,7 @@ optimize_type_concat(NODE *node) } void -code_type_concat(NODE *node, struct locus **old_locus) +code_type_concat(NODE *node, struct mu_locus_range const **old_locus) { code_node(node->v.concat.arg[0]); code_node(node->v.concat.arg[1]); @@ -1313,9 +1317,9 @@ mark_type_variable(NODE *node) } void -code_type_variable(NODE *node, struct locus **old_locus) +code_type_variable(NODE *node, struct mu_locus_range const **old_locus) { - MARK_LOCUS(); + mark_locus(node, old_locus); code_memref(node); code_op(opcode_deref); } @@ -1355,7 +1359,7 @@ optimize_type_asgn(NODE *node) } void -code_type_asgn(NODE *node, struct locus **old_locus) +code_type_asgn(NODE *node, struct mu_locus_range const **old_locus) { code_node(node->v.asgn.node); node->v.asgn.var->type = node_type(node->v.asgn.node); @@ -1382,9 +1386,9 @@ code_argref(NODE *node) } void -code_type_arg(NODE *node, struct locus **old_locus) +code_type_arg(NODE *node, struct mu_locus_range const **old_locus) { - MARK_LOCUS(); + mark_locus(node, old_locus); code_argref(node); code_op(opcode_deref); } @@ -1421,9 +1425,9 @@ code_argxref(NODE *node) } void -code_type_argx(NODE *node, struct locus **old_locus) +code_type_argx(NODE *node, struct mu_locus_range const **old_locus) { - MARK_LOCUS(); + mark_locus(node, old_locus); code_argxref(node); code_op(opcode_deref); } @@ -1456,10 +1460,10 @@ mark_type_vaptr(NODE *node) } void -code_type_vaptr(NODE *node, struct locus **old_locus) +code_type_vaptr(NODE *node, struct mu_locus_range const **old_locus) { NODE *arg = node->v.node; - MARK_LOCUS(); + mark_locus(node, old_locus); switch (arg->type) { case node_type_variable: code_memref(arg); @@ -1543,7 +1547,7 @@ mark_type_regex(NODE *node) } void -code_type_regex(NODE *node, struct locus **old_locus) +code_type_regex(NODE *node, struct mu_locus_range const **old_locus) { code_op(opcode_regex); code_immediate(node->v.regex->index, size); @@ -1595,7 +1599,7 @@ optimize_type_regcomp(NODE *node) } void -code_type_regcomp(NODE *node, struct locus **old_locus) +code_type_regcomp(NODE *node, struct mu_locus_range const **old_locus) { if (node->v.regcomp_data.regind == -1) save_regexp(node); @@ -1607,7 +1611,7 @@ code_type_regcomp(NODE *node, struct locus **old_locus) struct trycatch_stack_entry { int istry; - struct locus *locus; + struct mu_locus_range locus; unsigned id; }; @@ -1623,14 +1627,15 @@ trycatch_last_id(void) } static void -enter_trycatch(int istry, struct locus *locus) +enter_trycatch(int istry, struct mu_locus_range const *locus) { struct trycatch_stack_entry ent; if (!trycatch_stack) trycatch_stack = mf_stack_create(sizeof(ent), 0); ent.istry = istry; - ent.locus = locus; + mu_locus_range_init(&ent.locus); + mu_locus_range_copy(&ent.locus, locus); ent.id = trycatch_last_id() + 1; mf_stack_push(trycatch_stack, &ent); } @@ -1638,7 +1643,10 @@ enter_trycatch(int istry, struct locus *locus) static void leave_trycatch() { - mf_stack_pop(trycatch_stack, NULL); + struct trycatch_stack_entry ent; + if (mf_stack_pop(trycatch_stack, &ent) == 0) + mu_locus_range_deinit(&ent.locus); + } static int @@ -1698,12 +1706,12 @@ optimize_type_catch(NODE *node) } void -code_type_catch(NODE *node, struct locus **old_locus) +code_type_catch(NODE *node, struct mu_locus_range const **old_locus) { prog_counter_t pos1, endpos; prog_counter_t ctr; - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_catch); pos1 = code_immediate(NULL, ptr); code_exmask(node->v.catch.exmask); @@ -1763,7 +1771,7 @@ optimize_type_try(NODE *node) } void -code_type_try(NODE *node, struct locus **old_locus) +code_type_try(NODE *node, struct mu_locus_range const **old_locus) { prog_counter_t pos, ctr, pos1; prog_counter_t try_jmp_pc, catch_jmp_pc; @@ -1801,7 +1809,7 @@ code_type_try(NODE *node, struct locus **old_locus) code_put(pos1, (pos - pos1), long); /* Compile `try' part */ - MARK_LOCUS(); + mark_locus(node, old_locus); jump_pc = 0; enter_trycatch(1, &node->v.try.node->locus); traverse_tree(node->v.try.node); @@ -1860,10 +1868,10 @@ optimize_type_throw(NODE *node) } void -code_type_throw(NODE *node, struct locus **old_locus) +code_type_throw(NODE *node, struct mu_locus_range const **old_locus) { code_node(node->v.throw.expr); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_throw); code_immediate(node->v.throw.code, ulong); } @@ -1891,10 +1899,10 @@ optimize_type_echo(NODE *node) } void -code_type_echo(NODE *node, struct locus **old_locus) +code_type_echo(NODE *node, struct mu_locus_range const **old_locus) { code_node(node->v.node); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_echo); } @@ -1923,15 +1931,15 @@ optimize_type_return(NODE *node) } void -code_type_return(NODE *node, struct locus **old_locus) +code_type_return(NODE *node, struct mu_locus_range const **old_locus) { if (func->rettype == dtype_unspecified) { - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_jmp); jump_pc = code_immediate(jump_pc, long); } else { code_node(node->v.node); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_popreg); code_op(opcode_jmp); jump_pc = code_immediate(jump_pc, long); @@ -1968,7 +1976,7 @@ optimize_type_call(NODE *node) } void -code_type_call(NODE *node, struct locus **old_locus) +code_type_call(NODE *node, struct mu_locus_range const **old_locus) { NODE *p; struct literal *s; @@ -2000,7 +2008,7 @@ code_type_call(NODE *node, struct locus **old_locus) for (p = node->v.call.args, i = 0; p; p = p->next, i++) code_node(p); - MARK_LOCUS(); + mark_locus(node, old_locus); if (func->entry == 0) { parse_error("INTERNAL ERROR at %s:%d: unresolved function %s", __FILE__, __LINE__, func->sym.name); @@ -2242,13 +2250,13 @@ L2: static void code_switch_branches(NODE *node, data_type_t type) { - prog_counter_t start, refpos, jmppos; + prog_counter_t refpos, jmppos; struct case_stmt *pcase; size_t data_off = node->v.switch_stmt.off; code_op(opcode_popreg); code_op(type == dtype_number ? opcode_xlat : opcode_xlats); - start = code_immediate(node->v.switch_stmt.tabsize, ulong); + code_immediate(node->v.switch_stmt.tabsize, ulong); code_immediate(data_off, size); code_op(opcode_bnz); code_immediate(1, long); @@ -2291,7 +2299,7 @@ code_switch_branches(NODE *node, data_type_t type) } void -code_type_switch(NODE *node, struct locus **old_locus) +code_type_switch(NODE *node, struct mu_locus_range const **old_locus) { code_node(node->v.switch_stmt.node); code_switch_branches(node, node_type(node->v.switch_stmt.node)); @@ -2374,11 +2382,11 @@ print_type_next(NODE *node, int level) } void -code_type_next(NODE *node, struct locus **old_locus) +code_type_next(NODE *node, struct mu_locus_range const **old_locus) { struct loop_stack ent; - MARK_LOCUS(); + mark_locus(node, old_locus); if (find_loop(node->v.literal, &ent) == 0) { parse_error_locus(&node->locus, @@ -2406,11 +2414,11 @@ print_type_break(NODE *node, int level) } void -code_type_break(NODE *node, struct locus **old_locus) +code_type_break(NODE *node, struct mu_locus_range const **old_locus) { struct loop_stack ent; - MARK_LOCUS(); + mark_locus(node, old_locus); if (find_loop(node->v.literal, &ent) == 0) { parse_error_locus(&node->locus, @@ -2497,7 +2505,7 @@ optimize_type_loop(NODE *node) } void -code_type_loop(NODE *node, struct locus **old_locus) +code_type_loop(NODE *node, struct mu_locus_range const **old_locus) { /* FIXME */ /* @@ -2516,7 +2524,7 @@ code_type_loop(NODE *node, struct locus **old_locus) */ prog_counter_t begin, end, stmt, endjmp = 0, nxtjmp = 0; - MARK_LOCUS(); + mark_locus(node, old_locus); enter_loop(node->v.loop.ident, &endjmp, &nxtjmp); @@ -2559,9 +2567,9 @@ print_type_backref(NODE *node, int level) } void -code_type_backref(NODE *node, struct locus **old_locus) +code_type_backref(NODE *node, struct mu_locus_range const **old_locus) { - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_backref); code_immediate(node->v.number, uint); } @@ -2608,7 +2616,7 @@ optimize_type_cast(NODE *node) } int -code_cast(struct locus *locus, data_type_t fromtype, data_type_t totype) +code_cast(struct mu_locus_range const *locus, data_type_t fromtype, data_type_t totype) { if (fromtype == totype) return 0; @@ -2633,7 +2641,7 @@ code_cast(struct locus *locus, data_type_t fromtype, data_type_t totype) } void -code_type_cast(NODE *node, struct locus **old_locus) +code_type_cast(NODE *node, struct mu_locus_range const **old_locus) { code_node(node->v.cast.node); code_cast(&node->v.cast.node->locus, @@ -2656,7 +2664,7 @@ optimize_type_funcdecl(NODE *node) } void -code_type_funcdecl(NODE *node, struct locus **old_locus) +code_type_funcdecl(NODE *node, struct mu_locus_range const **old_locus) { prog_counter_t pc; @@ -2685,7 +2693,7 @@ optimize_type_progdecl(NODE *node) } void -code_type_progdecl(NODE *node, struct locus **old_locus) +code_type_progdecl(NODE *node, struct mu_locus_range const **old_locus) { enum smtp_state tag; @@ -2745,9 +2753,9 @@ optimize_type_offset(NODE *node) } void -code_type_offset(NODE *node, struct locus **old_locus) +code_type_offset(NODE *node, struct mu_locus_range const **old_locus) { - MARK_LOCUS(); + mark_locus(node, old_locus); switch (node->v.var_ref.variable->storage_class) { case storage_extern: code_op(opcode_push); diff --git a/src/exclist.c b/src/exclist.c index 81db7207..40a8074b 100644 --- a/src/exclist.c +++ b/src/exclist.c @@ -31,7 +31,7 @@ static struct exclist *head, *tail; size_t exception_count = 0; void -define_exception(struct literal *lit, struct locus *locus) +define_exception(struct literal *lit, struct mu_locus_range const *locus) { const struct constant *cp; struct value value; @@ -22,6 +22,7 @@ #include <fnmatch.h> #include <netdb.h> #include "mailfromd.h" +#include <mailutils/yyloc.h> #include "prog.h" #include "optab.h" @@ -38,23 +39,25 @@ static NODE *reverse(NODE *in); static size_t nodelistlength(NODE *list); static NODE *function_call(struct function *function, size_t count, NODE *subtree); -static NODE *declare_function(struct function *func, struct locus *loc, +static NODE *declare_function(struct function *func, + struct mu_locus_range const *loc, size_t nautos); static data_type_t node_type(NODE *node); static NODE *cast_arg_list(NODE *args, size_t parmc, data_type_t *parmtype, int disable_prom); -void add_xref(struct variable *var, const struct locus *locus); +void add_xref(struct variable *var, struct mu_locus_range const *locus); static struct variable *vardecl(const char *name, data_type_t type |