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 | 23 | ||||
-rw-r--r-- | src/drivers.c | 178 | ||||
-rw-r--r-- | src/exclist.c | 2 | ||||
-rw-r--r-- | src/gram.y | 584 | ||||
-rw-r--r-- | src/lex.l | 199 | ||||
-rw-r--r-- | src/mailfromd.h | 61 | ||||
-rw-r--r-- | src/main.c | 28 | ||||
-rw-r--r-- | src/pp.c | 73 | ||||
-rw-r--r-- | src/prog.c | 55 | ||||
-rw-r--r-- | src/prog.h | 16 | ||||
-rw-r--r-- | src/symbols.c | 33 |
17 files changed, 677 insertions, 655 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 @@ -68,14 +68,10 @@ 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); } 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 @@ -18,3 +18,3 @@ MF_DEFUN(set_from, VOID, STRING addr, OPTIONAL, STRING args) { - struct locus locus; + struct mu_locus_range locus; @@ -22,5 +22,5 @@ MF_DEFUN(set_from, VOID, STRING addr, OPTIONAL, STRING args) - 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), 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 @@ -18,3 +18,3 @@ MF_DEFUN(header_add, VOID, STRING name, STRING value, OPTIONAL, NUMBER idx) { - struct locus locus; + struct mu_locus_range locus; @@ -23,5 +23,5 @@ MF_DEFUN(header_add, VOID, STRING name, STRING value, OPTIONAL, NUMBER idx) 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), @@ -31,5 +31,5 @@ MF_DEFUN(header_add, VOID, STRING name, STRING value, OPTIONAL, NUMBER 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), @@ -43,3 +43,3 @@ MF_DEFUN(header_insert, VOID, STRING name, STRING value, NUMBER idx) { - struct locus locus; + struct mu_locus_range locus; @@ -47,5 +47,5 @@ MF_DEFUN(header_insert, VOID, STRING name, STRING value, NUMBER 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), @@ -59,3 +59,3 @@ MF_DEFUN(header_delete, VOID, STRING name, OPTIONAL, NUMBER idx) { - struct locus locus; + struct mu_locus_range locus; @@ -63,5 +63,5 @@ MF_DEFUN(header_delete, VOID, STRING name, OPTIONAL, NUMBER idx) - 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), @@ -75,3 +75,3 @@ MF_DEFUN(header_delete_nth, VOID, NUMBER idx) { - struct locus locus; + struct mu_locus_range locus; @@ -79,5 +79,5 @@ MF_DEFUN(header_delete_nth, VOID, NUMBER idx) - 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), @@ -90,3 +90,3 @@ MF_DEFUN(header_replace, VOID, STRING name, STRING value, OPTIONAL, NUMBER idx) { - struct locus locus; + struct mu_locus_range locus; @@ -94,5 +94,5 @@ MF_DEFUN(header_replace, VOID, STRING name, STRING value, OPTIONAL, NUMBER idx) - 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), @@ -106,3 +106,3 @@ MF_DEFUN(header_replace_nth, VOID, NUMBER idx, STRING name, STRING value) { - struct locus locus; + struct mu_locus_range locus; @@ -110,5 +110,5 @@ MF_DEFUN(header_replace_nth, VOID, NUMBER idx, STRING name, STRING value) - 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), 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 @@ -19,3 +19,3 @@ MF_DEFUN(progress, VOID) { - struct locus locus; + struct mu_locus_range locus; @@ -23,5 +23,5 @@ MF_DEFUN(progress, VOID) - 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"); 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 @@ -18,3 +18,3 @@ MF_DEFUN(quarantine, VOID, STRING reason) { - struct locus locus; + struct mu_locus_range locus; @@ -22,5 +22,5 @@ MF_DEFUN(quarantine, VOID, STRING reason) - 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), 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 @@ -18,3 +18,3 @@ MF_DEFUN(rcpt_add, VOID, STRING addr) { - struct locus locus; + struct mu_locus_range locus; @@ -22,5 +22,5 @@ MF_DEFUN(rcpt_add, VOID, STRING addr) - 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), @@ -33,3 +33,3 @@ MF_DEFUN(rcpt_delete, VOID, STRING addr) { - struct locus locus; + struct mu_locus_range locus; @@ -37,5 +37,5 @@ MF_DEFUN(rcpt_delete, VOID, STRING addr) - 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), 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 @@ -48,3 +48,3 @@ _sieve_file_action_log(mu_sieve_machine_t mach, eval_environ_t env = mu_sieve_get_data(mach); - struct locus locus; + struct mu_locus_range locus; @@ -54,5 +54,6 @@ _sieve_file_action_log(mu_sieve_machine_t mach, 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, @@ -79,3 +80,3 @@ 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) { @@ -112,4 +113,5 @@ MF_DEFUN(sieve, NUMBER, NUMBER nmsg, STRING script, OPTIONAL, NUMBER flags, 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); @@ -117,5 +119,6 @@ MF_DEFUN(sieve, NUMBER, NUMBER nmsg, STRING script, OPTIONAL, NUMBER flags, 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 { diff --git a/src/drivers.c b/src/drivers.c index 3b98ccc9..cbca6a5b 100644 --- a/src/drivers.c +++ b/src/drivers.c @@ -16,10 +16,14 @@ -#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); + } +} @@ -76,5 +80,5 @@ 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); @@ -94,5 +98,5 @@ 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); @@ -117,5 +121,5 @@ 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); @@ -200,3 +204,3 @@ 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) { @@ -205,3 +209,3 @@ code_type_if(NODE *node, struct locus **old_locus) code_node(node->v.cond.cond); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_bz); @@ -769,3 +773,3 @@ optimize_type_bin(NODE *node) void -code_type_bin(NODE *node, struct locus **old_locus) +code_type_bin(NODE *node, struct mu_locus_range const **old_locus) { @@ -777,3 +781,3 @@ code_type_bin(NODE *node, struct locus **old_locus) case bin_and: - MARK_LOCUS(); + mark_locus(node, old_locus); /* cond1 @@ -801,3 +805,3 @@ code_type_bin(NODE *node, struct locus **old_locus) case bin_or: - MARK_LOCUS(); + mark_locus(node, old_locus); /* cond1 @@ -857,3 +861,3 @@ code_type_bin(NODE *node, struct locus **old_locus) code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); if (node->v.bin.qualifier & QUALIFIER_MX) @@ -866,3 +870,3 @@ code_type_bin(NODE *node, struct locus **old_locus) code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); if (node->v.bin.qualifier & QUALIFIER_MX) @@ -875,3 +879,3 @@ code_type_bin(NODE *node, struct locus **old_locus) code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_add); @@ -881,3 +885,3 @@ code_type_bin(NODE *node, struct locus **old_locus) code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_sub); @@ -887,3 +891,3 @@ code_type_bin(NODE *node, struct locus **old_locus) code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_mul); @@ -893,3 +897,3 @@ code_type_bin(NODE *node, struct locus **old_locus) code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_div); @@ -899,3 +903,3 @@ code_type_bin(NODE *node, struct locus **old_locus) code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_mod); @@ -905,3 +909,3 @@ code_type_bin(NODE *node, struct locus **old_locus) code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_logand); @@ -911,3 +915,3 @@ code_type_bin(NODE *node, struct locus **old_locus) code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_logor); @@ -917,3 +921,3 @@ code_type_bin(NODE *node, struct locus **old_locus) code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_logxor); @@ -923,3 +927,3 @@ code_type_bin(NODE *node, struct locus **old_locus) code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_shl); @@ -929,3 +933,3 @@ code_type_bin(NODE *node, struct locus **old_locus) code_node(node->v.bin.arg[1]); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_shr); @@ -989,6 +993,6 @@ 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) { @@ -1078,3 +1082,3 @@ 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) { @@ -1115,3 +1119,3 @@ code_type_result(NODE *node, struct locus **old_locus) - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_result); @@ -1147,5 +1151,5 @@ 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) @@ -1213,3 +1217,3 @@ 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) { @@ -1229,3 +1233,3 @@ code_type_builtin(NODE *node, struct locus **old_locus) - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_builtin); @@ -1287,3 +1291,3 @@ 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) { @@ -1315,5 +1319,5 @@ 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); @@ -1357,3 +1361,3 @@ 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) { @@ -1384,5 +1388,5 @@ 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); @@ -1423,5 +1427,5 @@ 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); @@ -1458,6 +1462,6 @@ 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) { @@ -1545,3 +1549,3 @@ 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) { @@ -1597,3 +1601,3 @@ 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) { @@ -1609,3 +1613,3 @@ struct trycatch_stack_entry { int istry; - struct locus *locus; + struct mu_locus_range locus; unsigned id; @@ -1625,3 +1629,3 @@ trycatch_last_id(void) static void -enter_trycatch(int istry, struct locus *locus) +enter_trycatch(int istry, struct mu_locus_range const *locus) { @@ -1632,3 +1636,4 @@ enter_trycatch(int istry, struct locus *locus) 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; @@ -1640,3 +1645,6 @@ 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); + } @@ -1700,3 +1708,3 @@ 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) { @@ -1705,3 +1713,3 @@ code_type_catch(NODE *node, struct locus **old_locus) - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_catch); @@ -1765,3 +1773,3 @@ 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) { @@ -1803,3 +1811,3 @@ code_type_try(NODE *node, struct locus **old_locus) /* Compile `try' part */ - MARK_LOCUS(); + mark_locus(node, old_locus); jump_pc = 0; @@ -1862,6 +1870,6 @@ 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); @@ -1893,6 +1901,6 @@ 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); @@ -1925,6 +1933,6 @@ 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); @@ -1933,3 +1941,3 @@ code_type_return(NODE *node, struct locus **old_locus) code_node(node->v.node); - MARK_LOCUS(); + mark_locus(node, old_locus); code_op(opcode_popreg); @@ -1970,3 +1978,3 @@ 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) { @@ -2002,3 +2010,3 @@ code_type_call(NODE *node, struct locus **old_locus) - MARK_LOCUS(); + mark_locus(node, old_locus); if (func->entry == 0) { @@ -2244,3 +2252,3 @@ code_switch_branches(NODE *node, data_type_t type) { - prog_counter_t start, refpos, jmppos; + prog_counter_t refpos, jmppos; struct case_stmt *pcase; @@ -2250,3 +2258,3 @@ code_switch_branches(NODE *node, data_type_t type) 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); @@ -2293,3 +2301,3 @@ 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) { @@ -2376,3 +2384,3 @@ 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) { @@ -2380,3 +2388,3 @@ code_type_next(NODE *node, struct locus **old_locus) - MARK_LOCUS(); + mark_locus(node, old_locus); @@ -2408,3 +2416,3 @@ 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) { @@ -2412,3 +2420,3 @@ code_type_break(NODE *node, struct locus **old_locus) - MARK_LOCUS(); + mark_locus(node, old_locus); @@ -2499,3 +2507,3 @@ 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) { @@ -2518,3 +2526,3 @@ code_type_loop(NODE *node, struct locus **old_locus) - MARK_LOCUS(); + mark_locus(node, old_locus); @@ -2561,5 +2569,5 @@ 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); @@ -2610,3 +2618,3 @@ 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) { @@ -2635,3 +2643,3 @@ 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) { @@ -2658,3 +2666,3 @@ 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) { @@ -2687,3 +2695,3 @@ 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) { @@ -2747,5 +2755,5 @@ 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) { diff --git a/src/exclist.c b/src/exclist.c index 81db7207..40a8074b 100644 --- a/src/exclist.c +++ b/src/exclist.c @@ -33,3 +33,3 @@ 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) { @@ -24,2 +24,3 @@ #include "mailfromd.h" +#include <mailutils/yyloc.h> #include "prog.h" @@ -40,3 +41,4 @@ 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); @@ -45,14 +47,15 @@ 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, - storage_class_t sc, struct locus *loc); + storage_class_t sc, + struct mu_locus_range const *loc); static struct variable *externdecl(const char *name, struct value *value, - struct locus *loc); + struct mu_locus_range const *loc); static int initialize_variable(struct variable *var, struct value *val, - const struct locus *locus); + struct mu_locus_range const *locus); static void apply_deferred_init(void); static NODE *create_asgn_node(struct variable *var, NODE *expr, - const struct locus *loc); + struct mu_locus_range const *loc); -NODE *defined_parm(struct variable *var, struct locus *locus); +NODE *defined_parm(struct variable *var, struct mu_locus_range const *locus); @@ -213,3 +216,3 @@ type_to_string(data_type_t t) static int -check_func_usage(struct function *fp, const struct locus *locus) +check_func_usage(struct function *fp, struct mu_locus_range const *locus) { @@ -220,3 +223,3 @@ check_func_usage(struct function *fp, const struct locus *locus) _("function `%s' cannot be used in " - "prog `%s'"), + "prog `%s'"), fp->sym.name, @@ -238,3 +241,4 @@ check_func_usage(struct function *fp, const struct locus *locus) static int -check_builtin_usage(const struct builtin *bp) +check_builtin_usage(const struct builtin *bp, + struct mu_locus_range const *locus) { @@ -243,6 +247,7 @@ check_builtin_usage(const struct builtin *bp) if (bp->statemask && !(STATMASK(state_tag) & bp->statemask)) { - parse_error(_("built-in function `%s' cannot be used in " - "prog `%s'"), - bp->name, - state_to_string(state_tag)); + parse_error_locus(locus, + _("built-in function `%s' cannot be used in " + "prog `%s'"), + bp->name, + state_to_string(state_tag)); return 1; @@ -282,28 +287,2 @@ _create_alias(void *item, void *data) } - -#define YYLLOC_DEFAULT(Current, Rhs, N) \ - do { \ - if (N) { \ - (Current).beg = YYRHSLOC(Rhs, 1).beg; \ - (Current).end = YYRHSLOC(Rhs, N).end; \ - } else { \ - (Current).beg = YYRHSLOC(Rhs, 0).end; \ - (Current).end = (Current).beg; \ - } \ - } while (0) - -#define YY_LOCATION_PRINT(File, Loc) do { \ - if (LOCUS_EQ(&(Loc).beg, &(Loc).end)) \ - fprintf(File, "%s:%lu.%lu-%lu.%lu", \ - (Loc).beg.file, \ - (Loc).beg.line, (Loc).beg.point, \ - (Loc).end.line, (Loc).end.point); \ - else \ - fprintf(File, "%s:%lu.%lu-%s:%lu.%lu", \ - (Loc).beg.file, \ - (Loc).beg.line, (Loc).beg.point, \ - (Loc).end.file, \ - (Loc).end.line, (Loc).end.point); \ - } while (0) - %} @@ -578,6 +557,9 @@ moddecl : T_MODULE literal '.' { - if (top_module->dclname) - parse_error_locus(&@2.beg, + if (top_module->dclname) { + struct mu_locus_range lr; + lr.beg = @1.beg; + lr.end = @3.end; + parse_error_locus(&lr, _("duplicate module declaration")); - else + } else top_module->dclname = $2->text; @@ -586,8 +568,11 @@ moddecl : T_MODULE literal '.' { - if (top_module->dclname) - parse_error_locus(&@2.beg, + if (top_module->dclname) { + struct mu_locus_range lr; + lr.beg = @1.beg; + lr.end = @4.end; + parse_error_locus(&lr, _("duplicate module declaration")); - else { + } else { if (($3 & (SYM_STATIC|SYM_PUBLIC)) == 0) - parse_error_locus(&@3.beg, + parse_error_locus(&@3, _("invalid module declaration")); @@ -635,3 +620,3 @@ decl : T_PROG state_ident T_DO stmtlist T_DONE { - $$ = alloc_node(node_type_progdecl, &@1.beg); + $$ = alloc_node(node_type_progdecl, &@1); $$->v.progdecl.tag = $2; @@ -650,3 +635,3 @@ decl : T_PROG state_ident T_DO stmtlist T_DONE if (!np) { - np = alloc_node(node_type_progdecl, &@1.beg); + np = alloc_node(node_type_progdecl, &@1); $$ = progspecial[$1.code] = np; @@ -673,3 +658,3 @@ decl : T_PROG state_ident T_DO stmtlist T_DONE if ($1 & SYM_PRECIOUS) - parse_error_locus(&@2.beg, + parse_error_locus(&@2, _("`precious' used with func")); @@ -677,3 +662,3 @@ decl : T_PROG state_ident T_DO stmtlist T_DONE (SYM_STATIC|SYM_PUBLIC)) - parse_error_locus(&@2.beg, + parse_error_locus(&@2, _("`static' and `public' " @@ -682,3 +667,3 @@ decl : T_PROG state_ident T_DO stmtlist T_DONE func->node = $5.head; - $$ = declare_function(func, &@2.beg, + $$ = declare_function(func, &@2, forget_autos(PARMCOUNT() + FUNC_HIDDEN_ARGS(func), @@ -729,6 +714,6 @@ vardecl : qualifiers T_TYPE varname == (SYM_STATIC|SYM_PUBLIC)) - parse_error_locus(&@1.beg, + parse_error_locus(&@1, _("`static' and `public' " - "used together")); - var = vardecl($3->text, $2, storage_extern, NULL); + "used together")); + var = vardecl($3->text, $2, storage_extern, &@3); if (!var) @@ -744,7 +729,7 @@ vardecl : qualifiers T_TYPE varname == (SYM_STATIC|SYM_PUBLIC)) - parse_error_locus(&@1.beg, + parse_error_locus(&@1, _("`static' and `public' " - "used together")); + "used together")); - |