pike.git
/
src
/
program.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/program.c:7854:
/*! @decl void report(SeverityLevel severity, @ *! string filename, int linenumber, @ *! string subsystem, @ *! string message, mixed ... extra_args) *! *! Report a diagnostic from the compiler. *! *! @param severity *! The severity of the diagnostic. *!
-
*! The default implementation does the following depending on @[severity]:
-
*! @int
-
*! @value NOTICE
-
*! Ignored.
-
*! @value WARNING
-
*! Calls @[MasterObject()->compile_warning()].
-
*! @value ERROR
-
*! @value FATAL
-
*! Calls @[MasterObject()->compile_error()].
-
*! @endint
-
*!
-
*! If there's no master object yet, the diagnostic is output to
-
*! @[Stdio.stderr].
-
*!
+
*! @param filename *! @param linenumber *! Location which triggered the diagnostic. *! *! @param subsystem *! Compiler subsystem that generated the diagnostic. *! *! @param message *! @[sprintf()]-style formatting string with the diagnostic message. *! *! @param extra_args *! Extra arguments to @[sprintf()]. *!
-
+
*! The default implementation does the following:
+
*!
+
*! @ul
+
*! @item
+
*! If there's a @[MasterObject()->report()], call it
+
*! with the same arguments as ourselves.
+
*! @item
+
*! Otherwise depending on @[severity]:
+
*! @int
+
*! @value NOTICE
+
*! Ignored.
+
*! @value WARNING
+
*! Calls @[MasterObject()->compile_warning()].
+
*! @value ERROR
+
*! @value FATAL
+
*! Calls @[MasterObject()->compile_error()].
+
*! @endint
+
*! @endul
+
*!
+
*! If there's no master object yet, the diagnostic is output to
+
*! @[Stdio.stderr].
+
*!
+
*! @note
+
*! In Pike 7.8 and earlier @[MasterObject()->report()] was not called.
+
*!
*! @seealso *! @[PikeCompiler()->report()] */ static void f_compilation_env_report(INT32 args) { int level; struct pike_string *filename; INT_TYPE linenumber; struct pike_string *subsystem; struct pike_string *message;
-
+
struct object *master_ob;
-
+
if ((master_ob = get_master()) && master_ob->prog) {
+
int fun = find_identifier("report", master_ob->prog);
+
if (fun >= 0) {
+
apply_low(master_ob, fun, args);
+
return;
+
}
+
}
+
if (args > 5) { f_sprintf(args - 4); args = 5; } get_all_args("report", args, "%d%W%i%W%W", &level, &filename, &linenumber, &subsystem, &message); /* Ignore informational level messages */ if (level >= REPORT_WARNING) {
-
if (
get
_master
(
)
)
{
+
if (
master
_
ob &&
master
_ob->prog
) {
ref_push_string(filename); push_int(linenumber); ref_push_string(message); if (level >= REPORT_ERROR) { APPLY_MASTER("compile_error", 3); args++; } else { APPLY_MASTER("compile_warning", 3); args++; }
pike.git/src/program.c:8637:
} } /*! @decl void report(SeverityLevel severity, @ *! string filename, int linenumber, @ *! string subsystem, @ *! string message, mixed ... extra_args) *! *! Report a diagnostic from the compiler. *!
-
*! The default implementation
calls
the
corresponding
function
-
*! in the active handlers
,
and
otherwise
falls
back
to
-
*! @[CompilerEnvironment()->report()] in the parent object.
+
*! The default implementation
attempts
to call
the
first
+
*!
corresponding function
in the active handlers
in
priority
order:
+
*!
+
*! @ol
+
*!
@item
+
*! Call handler->report().
+
*! @item
+
*! Call handler->compile_warning() or handler->compile_error()
+
*! depending on
@[
severity].
+
*! @item
+
*! Call compat->report().
+
*! @item
+
*! Call compat->compile_warning() or compat->compile_error()
+
*! depending on @[severity].
+
*! @item
+
*! Fallback: Call @[
CompilerEnvironment()->report()]
+
*!
in the parent object.
+
*! @endol
+
*!
+
*! The arguments will be as follows:
+
*! @dl
+
*! @item report()
+
*! The report() function will be called with the same arguments
+
*! as this function.
+
*! @item compile_warning()/compile_error()
+
*! Depending on the @[severity] either compile_warning()
+
*! or compile_error() will be called.
+
*!
+
*! They will be called with the @[filename], @[linenumber]
+
*! and formatted @[message] as arguments.
+
*!
+
*! Note that these will not be called for the @[NOTICE] severity,
+
*! and that compile_error() will be used for both @[ERROR] and
+
*! @[FATAL].
+
*! @enddl
+
*!
+
*! @note
+
*! In Pike 7.8 and earlier the report() function was not called
+
*! in the handlers.
+
*!
+
*! @seealso
+
*! @[CompilerEnvironment()->report()]
*/ static void f_compilation_report(INT32 args) { struct compilation *c = THIS_COMPILATION; int level; struct pike_string *filename; INT_TYPE linenumber; struct pike_string *subsystem; struct pike_string *message; struct object *handler = NULL; int fun = -1; /* FIXME: get_all_args() ought to have a marker * indicating that we accept more arguments... */ get_all_args("report", args, "%d", &level);
-
if ((c->handler || c->compat_handler)
&&
-
(level >= REPORT_WARNING
)
)
{
-
/* Ignore informational level messages */
+
if ((c->handler || c->compat_handler)) {
const char *fun_name = "compile_warning"; if (level >= REPORT_ERROR) fun_name = "compile_error"; if((handler = c->handler) && handler->prog) {
-
if ((fun = find_identifier(
fun_name
, handler->prog)) !=
-
-1) {
+
if ((fun = find_identifier(
"report"
, handler->prog)) !=
-1) {
+
apply_low(handler,
fun,
args);
+
return;
+
}
+
if ((fun = find_identifier(fun_name, handler
-
>prog)) != -
1) {
goto apply_handler; } } if ((handler = c->compat_handler) && handler->prog) {
-
if ((fun = find_identifier(
fun_name
, handler->prog)) !=
-
-1) {
+
if ((fun = find_identifier(
"report"
, handler->prog)) !=
-1) {
+
apply_low(handler,
fun,
args);
+
return;
+
}
+
if ((fun = find_identifier(fun_name, handler
-
>prog)) != -
1) {
goto apply_handler; } } } /* Nothing apropriate in any handlers. * Call the report() in our parent. */ apply_external(1, CE_REPORT_FUN_NUM, args); return; apply_handler:
-
+
/* Ignore informational level messages */
+
if (level < REPORT_WARNING) return;
if (args > 5) { f_sprintf(args - 4); args = 5; } get_all_args("report", args, "%d%W%i%W%W", &level, &filename, &linenumber, &subsystem, &message); ref_push_string(filename); push_int(linenumber);